:root {
  --ink: #eef6ff;
  --paper: rgba(13, 20, 31, 0.78);
  --paper-strong: rgba(9, 14, 23, 0.92);
  --line: rgba(235, 245, 255, 0.2);
  --muted: rgba(238, 246, 255, 0.72);
  --aqua: #6ee7d8;
  --gold: #f5c66b;
  --rose: #fb7185;
  --violet: #a78bfa;
  --leaf: #86efac;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  background: #101722;
}

button {
  color: inherit;
  font: inherit;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(238, 246, 255, 0.24);
  border-bottom-width: 3px;
  border-radius: 6px;
  background: rgba(238, 246, 255, 0.12);
  font-size: 0.78rem;
  font-weight: 800;
}

[hidden] {
  display: none !important;
}

.game-shell,
#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#game {
  display: block;
  cursor: crosshair;
}

.hud {
  position: fixed;
  z-index: 5;
  pointer-events: none;
}

.top-hud {
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  width: min(880px, calc(100% - 24px));
  transform: translateX(-50%);
}

.status-block,
.story-hud,
.help-hud,
.choice-panel,
.ending-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.status-block {
  min-width: 0;
  padding: 10px;
}

.status-block span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.status-block strong {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.meter-track {
  overflow: hidden;
  height: 12px;
  border: 1px solid rgba(238, 246, 255, 0.16);
  border-radius: 999px;
  background: rgba(238, 246, 255, 0.1);
}

.meter-track i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transform-origin: left center;
  transition: transform 180ms ease;
}

#meaningBar {
  background: linear-gradient(90deg, var(--gold), #fef08a);
}

#skillBar {
  background: linear-gradient(90deg, var(--aqua), #93c5fd);
}

#bondBar {
  background: linear-gradient(90deg, var(--rose), #f9a8d4);
}

#restBar {
  background: linear-gradient(90deg, var(--leaf), #bef264);
}

.story-hud {
  left: max(14px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  width: min(480px, calc(100% - 28px));
  padding: 14px;
}

.story-hud p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.story-hud strong {
  display: block;
  font-size: 0.95rem;
}

.help-hud {
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: grid;
  gap: 9px;
  min-width: 206px;
  padding: 12px;
}

.help-hud div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.start-button {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 11vh;
  display: grid;
  gap: 5px;
  min-width: min(340px, calc(100% - 44px));
  padding: 18px 24px;
  border: 1px solid rgba(238, 246, 255, 0.38);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(110, 231, 216, 0.95), rgba(30, 64, 175, 0.92));
  box-shadow: var(--shadow);
  cursor: pointer;
}

.start-button:hover,
.choice-actions button:hover,
.ending-panel button:hover {
  filter: brightness(1.07);
}

.start-button strong {
  font-size: 1.18rem;
}

.start-button span {
  color: rgba(238, 246, 255, 0.78);
  font-size: 0.82rem;
  font-weight: 700;
}

.choice-panel,
.ending-panel {
  position: fixed;
  z-index: 12;
  left: 50%;
  top: 50%;
  width: min(520px, calc(100% - 32px));
  padding: 20px;
  background: var(--paper-strong);
  transform: translate(-50%, -50%);
}

.choice-panel small,
.ending-panel small {
  color: var(--aqua);
  font-weight: 800;
}

.choice-panel h1,
.ending-panel h1 {
  margin: 8px 0 10px;
  font-size: 1.28rem;
}

.choice-panel p,
.ending-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.choice-effects {
  margin: 16px 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.choice-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice-actions button,
.ending-panel button {
  min-height: 42px;
  padding: 13px;
  border: 1px solid rgba(238, 246, 255, 0.28);
  border-radius: 8px;
  background: rgba(110, 231, 216, 0.18);
  text-align: left;
  cursor: pointer;
}

.ending-panel button {
  color: #08111c;
  background: var(--aqua);
  font-weight: 800;
}

.choice-actions button strong,
.choice-actions button small,
.choice-actions button span {
  display: block;
}

.choice-actions button strong {
  margin-bottom: 6px;
  font-size: 0.94rem;
}

.choice-actions button small {
  min-height: 2.8em;
  color: var(--muted);
  line-height: 1.4;
}

.choice-actions button span {
  margin-top: 9px;
  color: var(--aqua);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.45;
}

.touch-controls {
  position: fixed;
  z-index: 7;
  inset: auto 14px max(14px, env(safe-area-inset-bottom)) auto;
  display: none;
  align-items: end;
  justify-content: space-between;
  width: calc(100% - 28px);
  pointer-events: none;
}

.touch-controls button {
  width: 50px;
  height: 50px;
  border: 1px solid rgba(238, 246, 255, 0.3);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(9, 14, 23, 0.78);
  box-shadow: var(--shadow);
  font-weight: 900;
  touch-action: none;
  pointer-events: auto;
}

.touch-dpad {
  display: grid;
  grid-template-columns: repeat(3, 50px);
  grid-template-areas:
    ". up ."
    "left down right";
  gap: 5px;
}

.touch-dpad [data-move="keyw"] {
  grid-area: up;
}

.touch-dpad [data-move="keya"] {
  grid-area: left;
}

.touch-dpad [data-move="keys"] {
  grid-area: down;
}

.touch-dpad [data-move="keyd"] {
  grid-area: right;
}

.touch-actions {
  display: grid;
  gap: 8px;
}

.touch-actions > div {
  display: flex;
  gap: 6px;
}

.touch-actions .touch-select {
  width: 106px;
  color: #08111c;
  background: var(--aqua);
}

.ending-panel button {
  width: 100%;
  margin-top: 18px;
}

.center-notice {
  position: fixed;
  z-index: 8;
  left: 50%;
  top: 50%;
  max-width: min(460px, calc(100% - 40px));
  padding: 13px 18px;
  border: 1px solid rgba(238, 246, 255, 0.28);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(9, 14, 23, 0.72);
  box-shadow: var(--shadow);
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.96);
  transition: 160ms ease;
  pointer-events: none;
}

.center-notice.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

@media (max-width: 760px) {
  .top-hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .help-hud {
    display: none;
  }

  .story-hud {
    bottom: 130px;
  }

  .help-hud div {
    justify-content: flex-start;
    font-size: 0.76rem;
  }

  .choice-actions {
    grid-template-columns: 1fr;
  }

  .choice-panel {
    max-height: calc(100% - 26px);
    overflow-y: auto;
  }

  .touch-controls {
    display: flex;
  }
}

@media (pointer: coarse) {
  .touch-controls {
    display: flex;
  }
}
