:root {
  color-scheme: dark;
  --bg: #0e1513;
  --panel: rgba(18, 29, 25, 0.82);
  --panel-border: rgba(190, 222, 207, 0.17);
  --text: #edf5f0;
  --muted: #a7bab1;
  --accent: #e4b96d;
  --green: #8ed4b2;
  --cyan: #8de8d8;
  --danger: #ffb2a5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
}

body {
  color: var(--text);
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  position: relative;
  width: 100%;
  height: calc(100dvh - 90px);
  min-height: 560px;
  overflow: hidden;
  isolation: isolate;
}

.site-header,
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 52px;
  padding: 12px max(20px, calc((100vw - 1180px) / 2));
  color: #edf5f0;
  background: #0a110f;
}

.site-logo,
.site-nav a,
.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-logo {
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 800;
}

.site-nav,
.site-footer {
  display: flex;
  flex-wrap: wrap;
}

.site-nav {
  justify-content: flex-end;
  gap: 8px 18px;
  font-size: 0.78rem;
}

.site-nav a:hover,
.site-footer a:hover {
  color: var(--accent);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 38px;
  padding: 9px max(20px, calc((100vw - 1180px) / 2));
  color: #a7bab1;
  background: #111b18;
  font-size: 0.7rem;
}

.breadcrumb a {
  color: var(--cyan);
}

#scene {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  outline: none;
}

#scene.is-dragging {
  cursor: grabbing;
}

.ambient-noise {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.12;
  mix-blend-mode: soft-light;
  background-image:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.18) 0 0.6px, transparent 0.9px),
    radial-gradient(circle at 75% 70%, rgba(255, 255, 255, 0.12) 0 0.5px, transparent 0.8px);
  background-size: 5px 5px, 7px 7px;
}

.site-head {
  position: absolute;
  z-index: 3;
  top: max(22px, env(safe-area-inset-top));
  left: max(24px, env(safe-area-inset-left));
  max-width: min(450px, calc(100vw - 48px));
  pointer-events: none;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.38);
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 760;
  letter-spacing: 0.16em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 7px;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
}

h1 span {
  color: var(--cyan);
  font-size: 0.48em;
  font-weight: 650;
  letter-spacing: 0.16em;
  vertical-align: 0.18em;
}

.lead {
  max-width: 360px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(0.82rem, 1.4vw, 0.98rem);
  line-height: 1.65;
}

.game-hud {
  position: absolute;
  z-index: 3;
  top: max(24px, env(safe-area-inset-top));
  right: max(24px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, auto));
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: rgba(11, 20, 17, 0.66);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(16px);
}

.metric {
  display: grid;
  gap: 3px;
  min-width: 78px;
  padding: 10px 13px;
  border-left: 1px solid var(--panel-border);
}

.metric:first-child {
  border-left: 0;
}

.metric span,
.metric small {
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
}

.metric strong {
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.metric-time strong {
  color: var(--accent);
  font-size: 1rem;
}

.progress-panel {
  position: absolute;
  z-index: 3;
  top: 145px;
  left: max(24px, env(safe-area-inset-left));
  width: min(250px, calc(100vw - 48px));
  padding: 13px 15px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: rgba(11, 20, 17, 0.56);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(16px);
}

.progress-row + .progress-row {
  margin-top: 11px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.68rem;
}

.progress-label strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
}

.progress-value {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 120ms linear;
}

.progress-fill {
  background: var(--accent);
  box-shadow: 0 0 16px rgba(228, 185, 109, 0.55);
}

.progress-stable {
  background: var(--cyan);
  box-shadow: 0 0 16px rgba(141, 232, 216, 0.55);
}

.drag-hint {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  color: rgba(238, 246, 241, 0.88);
  background: rgba(10, 18, 15, 0.54);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.2);
  font-size: 0.74rem;
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity 240ms ease, transform 240ms ease;
  backdrop-filter: blur(12px);
}

.drag-hint span {
  color: var(--accent);
  font-size: 1rem;
}

.drag-hint.is-hidden {
  opacity: 0;
  transform: translate(-50%, 8px);
}

.control-panel {
  position: absolute;
  z-index: 4;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: min(360px, calc(100vw - 48px));
  padding: 16px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(20px) saturate(1.1);
}

.status-line {
  min-height: 2.9em;
  margin: 0 1px 11px;
  color: var(--text);
  font-size: 0.76rem;
  line-height: 1.45;
}

.action-grid,
.secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.secondary-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 8px;
}

.button {
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid rgba(220, 238, 229, 0.15);
  border-radius: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.button:hover:not(:disabled) {
  border-color: rgba(228, 185, 109, 0.48);
  background: rgba(228, 185, 109, 0.1);
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button-primary {
  color: #1a1710;
  border-color: rgba(228, 185, 109, 0.38);
  background: linear-gradient(135deg, #efce8a, #dba755);
  box-shadow: 0 10px 26px rgba(217, 161, 75, 0.12);
}

.button-primary:hover:not(:disabled) {
  border-color: rgba(255, 238, 197, 0.8);
  background: linear-gradient(135deg, #f4d99e, #e2b365);
}

.button-shake {
  color: #14211e;
  border-color: rgba(141, 232, 216, 0.38);
  background: rgba(141, 232, 216, 0.86);
}

.button-shake span {
  display: inline-grid;
  min-width: 1.45em;
  place-items: center;
  margin-left: 3px;
  border-radius: 99px;
  color: var(--text);
  background: rgba(14, 21, 19, 0.54);
}

.button-quiet {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 0.66rem;
}

.button-quiet.is-active {
  color: #102019;
  border-color: rgba(167, 225, 197, 0.74);
  background: rgba(167, 225, 197, 0.84);
}

.key-help {
  margin: 11px 1px 0;
  color: rgba(173, 192, 182, 0.72);
  font-size: 0.61rem;
  line-height: 1.55;
}

.overlay-panel {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: 50%;
  width: min(410px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid rgba(190, 222, 207, 0.24);
  border-radius: 18px;
  background: rgba(13, 25, 21, 0.92);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.48);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(24px);
}

.overlay-panel[hidden] {
  display: none;
}

.overlay-panel h2 {
  margin: 0 0 16px;
  font-size: 1.35rem;
}

.overlay-panel > p:not(.panel-kicker) {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.65;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 18px;
}

.result-grid div {
  display: grid;
  gap: 5px;
  min-height: 66px;
  padding: 10px;
  border: 1px solid var(--panel-border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.045);
}

.result-grid span {
  color: var(--muted);
  font-size: 0.64rem;
}

.result-grid strong {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.overlay-panel .button {
  width: 100%;
}

.visibility-panel {
  width: min(390px, calc(100vw - 32px));
}

.error-box {
  position: absolute;
  z-index: 10;
  top: 50%;
  left: 50%;
  width: min(480px, calc(100vw - 40px));
  margin: 0;
  padding: 16px 18px;
  border: 1px solid rgba(255, 178, 165, 0.4);
  border-radius: 14px;
  color: var(--danger);
  background: rgba(50, 17, 15, 0.92);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%);
}

.info-section,
.comments-stub,
.game-comment-section {
  width: min(1040px, calc(100% - 32px));
  margin-inline: auto;
}

.info-section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px 42px;
  padding: 54px 0 28px;
  color: #17201e;
}

.info-section article {
  min-width: 0;
  padding-top: 14px;
  border-top: 1px solid #9db1aa;
}

.info-section article:last-child {
  grid-column: 1 / -1;
}

.info-section h2,
.comments-stub h2 {
  margin: 0 0 7px;
  font-size: 1.18rem;
}

.info-section p,
.comments-stub p {
  margin: 0;
  color: #465a54;
  line-height: 1.8;
}

.info-section,
.game-comment-section,
.comments-stub {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
}

.game-comment-section,
.comments-stub {
  margin-bottom: 42px;
  color: #17201e;
}

.game-comment-note {
  color: #465a54;
}

.app-comments,
.app-comment-form-section,
.app-comment-form input,
.app-comment-form select,
.app-comment-form textarea {
  color: #17201e;
}

.app-comment-form input,
.app-comment-form select,
.app-comment-form textarea {
  background: #ffffff;
}

.sandseal-page {
  background: #f2f6f3;
}

.site-footer {
  justify-content: center;
  font-size: 0.75rem;
}

@media (max-width: 880px) {
  .site-head {
    max-width: min(48vw, 360px);
  }

  .game-hud {
    top: 104px;
    right: 16px;
    left: 16px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .metric {
    min-width: 0;
    padding: 8px 9px;
  }

  .progress-panel {
    top: 181px;
    right: 16px;
    left: 16px;
    width: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 10px 12px;
  }

  .progress-row + .progress-row {
    margin-top: 0;
  }

  .control-panel {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    width: auto;
    padding: 12px;
    border-radius: 16px;
  }

  .status-line {
    min-height: 2.45em;
    margin-bottom: 8px;
  }

  .key-help {
    display: none;
  }

  .drag-hint {
    bottom: 205px;
  }
}

@media (max-width: 580px) {
  .site-header {
    align-items: flex-start;
    padding: 10px 14px;
  }

  .site-nav {
    gap: 6px 12px;
    font-size: 0.68rem;
  }

  .breadcrumb {
    padding-inline: 14px;
  }

  .app-shell {
    height: calc(100dvh - 86px);
    min-height: 480px;
  }

  .site-head {
    top: max(14px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left));
    max-width: calc(100vw - 32px);
  }

  .eyebrow {
    margin-bottom: 5px;
    font-size: 0.57rem;
  }

  h1 {
    margin-bottom: 5px;
    font-size: 1.38rem;
  }

  .lead {
    max-width: 290px;
    font-size: 0.72rem;
  }

  .game-hud {
    top: 91px;
    right: 12px;
    left: 12px;
  }

  .metric {
    padding: 7px 6px;
  }

  .metric span,
  .metric small {
    font-size: 0.55rem;
  }

  .metric strong {
    font-size: 0.75rem;
  }

  .metric-time strong {
    font-size: 0.86rem;
  }

  .progress-panel {
    top: 159px;
    right: 12px;
    left: 12px;
    gap: 9px;
    padding: 8px 10px;
  }

  .progress-label {
    margin-bottom: 4px;
    font-size: 0.61rem;
  }

  .progress-track {
    height: 6px;
  }

  .control-panel {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    padding: 10px;
  }

  .status-line {
    min-height: 2.7em;
    font-size: 0.7rem;
  }

  .button {
    min-height: 36px;
    padding: 7px 6px;
    font-size: 0.66rem;
  }

  .secondary-actions {
    gap: 6px;
    margin-top: 6px;
  }

  .button-quiet {
    min-height: 32px;
    font-size: 0.6rem;
  }

  .drag-hint {
    bottom: 214px;
    max-width: calc(100vw - 28px);
    padding: 7px 10px;
    font-size: 0.64rem;
    white-space: nowrap;
  }

  .overlay-panel {
    padding: 18px;
  }

  .overlay-panel h2 {
    font-size: 1.18rem;
  }

  .result-grid div {
    min-height: 60px;
    padding: 8px;
  }

  .info-section {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-top: 38px;
  }

  .info-section article:last-child {
    grid-column: auto;
  }

  .site-footer {
    gap: 8px 14px;
    padding-inline: 16px;
  }
}

@media (max-width: 580px) and (max-height: 640px) {
  .app-shell.is-result-visible .game-hud,
  .app-shell.is-result-visible .progress-panel,
  .app-shell.is-result-visible .drag-hint,
  .app-shell.is-result-visible .control-panel {
    visibility: hidden;
  }
}

@media (max-height: 680px) and (min-width: 881px) {
  .site-head {
    top: 16px;
  }

  .game-hud {
    top: 16px;
  }

  .progress-panel {
    top: 125px;
  }

  .control-panel {
    bottom: 12px;
    padding: 12px;
  }

  .key-help {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .drag-hint,
  .button,
  .progress-value {
    transition: none;
  }
}
