:root {
  --ink: #17151a;
  --cream: #fff9ec;
  --accent: #ff3b30;
  --accent-2: #ffb800;
  --poster-bg: #1a6bff;
  --shadow-hard: 4px 4px 0px var(--ink);
  --shadow-hard-lg: 7px 7px 0px var(--ink);
  --font-display: 'Hiragino Kaku Gothic Std', 'Noto Sans TC', 'Arial Black', sans-serif;
  --font-ui: 'Hiragino Maru Gothic ProN', 'PingFang TC', 'Hiragino Sans', sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #141318;
  font-family: var(--font-ui);
  color: var(--ink);
  touch-action: none;
}

#app-shell {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #15141a;
  background-image:
    radial-gradient(rgba(255, 249, 236, 0.085) 1.5px, transparent 1.5px),
    radial-gradient(circle at 50% 35%, rgba(255, 184, 0, 0.06), transparent 60%);
  background-size: 22px 22px, 100% 100%;
  padding: 14px;
}

/* 9:16 Japanese Beverage Poster Stage */
#poster-frame {
  position: relative;
  width: min(100%, calc((100dvh - 28px) * 9 / 16));
  height: min(100dvh - 28px, calc(100vw * 16 / 9));
  max-width: 480px;
  max-height: 854px;
  aspect-ratio: 9 / 16;
  background: var(--poster-bg);
  border: 4px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 26px 68px rgba(0, 0, 0, 0.6), 0 0 0 3px var(--cream);
  overflow: hidden;
  cursor: pointer;
}

@media (max-width: 520px) {
  #app-shell { padding: 0; }
  #poster-frame {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    border-width: 0;
    box-shadow: none;
  }
}

/* Silkscreen transition curtain */
#poster-curtain {
  position: absolute;
  inset: 0;
  background: var(--cream);
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  transition: opacity 0.22s ease;
}
#poster-curtain.flash {
  opacity: 0.72;
  transition: opacity 0.05s ease;
}

/* Print registration crop marks */
.crop-mark {
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
  z-index: 6;
  opacity: 0.45;
}
.crop-mark::before, .crop-mark::after {
  content: '';
  position: absolute;
  background: var(--ink);
}
.crop-mark.tl { top: 8px; left: 8px; }
.crop-mark.tl::before { width: 10px; height: 2px; top: 0; left: 0; }
.crop-mark.tl::after { width: 2px; height: 10px; top: 0; left: 0; }
.crop-mark.tr { top: 8px; right: 8px; }
.crop-mark.tr::before { width: 10px; height: 2px; top: 0; right: 0; }
.crop-mark.tr::after { width: 2px; height: 10px; top: 0; right: 0; }
.crop-mark.bl { bottom: 8px; left: 8px; }
.crop-mark.bl::before { width: 10px; height: 2px; bottom: 0; left: 0; }
.crop-mark.bl::after { width: 2px; height: 10px; bottom: 0; left: 0; }
.crop-mark.br { bottom: 8px; right: 8px; }
.crop-mark.br::before { width: 10px; height: 2px; bottom: 0; right: 0; }
.crop-mark.br::after { width: 2px; height: 10px; bottom: 0; right: 0; }

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Top HUD */
#hud-top {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  pointer-events: none;
}

.hud-left, .hud-right, .hud-center {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}
.hud-center {
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}

.poster-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 11px;
  background: var(--cream);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease;
}
.poster-pill:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}
.poster-pill.active-mode {
  background: var(--accent-2);
}
.icon-pill {
  padding: 0 10px;
  font-size: 18px;
  line-height: 1;
}
.pill-divider { opacity: 0.45; }

.mode-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 12px;
  background: var(--ink);
  color: var(--cream);
  border: 2px solid var(--cream);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
}

.tremor-tag {
  padding: 2px 9px;
  background: #ff2e55;
  color: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  animation: tremorBlink 1.1s ease-in-out infinite;
}
@keyframes tremorBlink {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.poster-circle-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.poster-circle-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}
.poster-circle-btn.small {
  width: 32px;
  height: 32px;
  font-size: 14px;
  font-weight: 900;
}

/* Live Tension Meter */
#tension-meter {
  position: absolute;
  top: 66px;
  right: 16px;
  width: 126px;
  padding: 8px 10px;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--ink);
  z-index: 9;
  pointer-events: none;
  transition: transform 0.14s ease, background 0.15s ease;
}
#tension-meter.danger {
  background: #ffe3e0;
  transform: scale(1.06);
}
.tension-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.tension-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  opacity: 0.65;
}
.tension-mm {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: #e6243b;
}
#tension-value {
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
}
#tension-meter.danger #tension-value { color: #e6243b; }
.tension-bar-track {
  margin-top: 5px;
  width: 100%;
  height: 7px;
  background: rgba(23, 21, 26, 0.14);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
}
#tension-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #00c86f, #ffb800, #ff2e55);
  transition: width 0.05s linear;
}

/* Bottom HUD */
#hud-bottom {
  position: absolute;
  bottom: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  z-index: 9;
  pointer-events: none;
}

.hold-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  background: rgba(255, 249, 236, 0.95);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.hold-hint.holding {
  transform: scale(0.92);
  background: var(--accent-2);
}
.hold-hint.hidden-soft {
  opacity: 0;
  transform: translateY(8px);
}
.hold-ring {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--ink);
  animation: pulseDot 1.3s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

#poster-footer-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  background: var(--ink);
  color: var(--cream);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.footer-ch {
  padding: 1px 5px;
  background: var(--accent-2);
  color: var(--ink);
  border-radius: 4px;
  font-weight: 700;
  font-size: 9px;
}
#footer-jp {
  font-family: var(--font-ui);
  font-weight: 900;
  font-size: 11px;
}
.meta-dot { color: var(--accent-2); font-size: 8px; }

/* Overlays */
.poster-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(23, 21, 26, 0.36);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 20;
}
.hidden { display: none !important; }

/* Exhibition Poster Title Card */
.title-card {
  width: 100%;
  max-width: 348px;
  padding: 22px 20px 20px;
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 20px;
  box-shadow: var(--shadow-hard-lg);
  text-align: center;
}
.title-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.title-kicker {
  padding: 4px 9px;
  background: var(--ink);
  color: var(--cream);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
}
.title-vol {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: #ff3b30;
}
.title-jp {
  font-family: var(--font-display);
  font-size: 48px;
  line-height: 1.04;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-shadow: 3px 3px 0 #ffb800;
}
.title-en {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.36em;
  color: #1a6bff;
}
.title-visual-icons {
  margin: 16px 0 18px;
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.badge-chip {
  padding: 4px 9px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 2px 2px 0 var(--ink);
}
.chip-water { background: #4cc9ff; }
.chip-honey { background: #ffb800; }
.chip-soda { background: #26e07f; }
.chip-beer { background: #ffe066; }
.chip-boba { background: #e3b07a; }
.chip-mercury { background: #dde5f0; }

.cta-btn {
  width: 100%;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #ff3b30;
  color: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 5px 5px 0 var(--ink);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.cta-btn:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 var(--ink);
}
.cta-pulse {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ffe600;
  border: 2px solid var(--ink);
  animation: pulseDot 1s ease-in-out infinite;
}

.title-secondary-row {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}
.sub-cta-btn {
  flex: 1;
  height: 40px;
  background: #fff;
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 11px;
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.sub-cta-btn:active { transform: translate(2px, 2px); }
.sub-cta-btn.accent { background: #ffe033; }

.title-sub-hint {
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  opacity: 0.65;
}

/* Result Card */
.result-card {
  width: 100%;
  max-width: 326px;
  padding: 24px 20px 20px;
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 20px;
  box-shadow: var(--shadow-hard-lg);
  text-align: center;
  position: relative;
  animation: popIn 0.22s cubic-bezier(0.2, 1.35, 0.4, 1) forwards;
}
@keyframes popIn {
  0% { transform: scale(0.78) rotate(-2deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.result-stamp {
  position: absolute;
  top: -16px;
  right: -10px;
  padding: 6px 14px;
  background: #e6243b;
  color: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 10px;
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--font-display);
  font-size: 20px;
  transform: rotate(9deg);
  animation: stampSlam 0.3s cubic-bezier(0.2, 1.5, 0.4, 1) forwards;
}
@keyframes stampSlam {
  0% { transform: scale(2.1) rotate(18deg); opacity: 0; }
  100% { transform: scale(1) rotate(9deg); opacity: 1; }
}
.result-card.overflow .result-stamp {
  background: #17151a;
  color: #ffe600;
}
.result-grade {
  font-family: var(--font-display);
  font-size: 62px;
  line-height: 1;
  color: var(--ink);
  text-shadow: 4px 4px 0 #ffb800;
}
.result-card.overflow .result-grade {
  font-size: 40px;
  color: #e6243b;
  text-shadow: 3px 3px 0 #17151a;
  margin-top: 6px;
}
.result-score-wrap {
  margin: 10px auto 6px;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 14px;
  background: #17151a;
  color: var(--cream);
  border-radius: 10px;
  font-family: var(--font-mono);
}
.result-score-label { font-size: 10px; opacity: 0.7; letter-spacing: 0.1em; }
#result-score { font-size: 22px; font-weight: 700; color: #ffe600; }

.result-margin {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #e6243b;
  letter-spacing: 0.08em;
}
.result-gauge-wrap {
  margin: 8px auto 6px;
  width: 88%;
}
.result-gauge-bar {
  position: relative;
  height: 10px;
  background: rgba(23, 21, 26, 0.14);
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
}
#result-gauge-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00c86f, #ffb800, #ff2e55);
}
.result-gauge-limit {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--ink);
}

.result-sub {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  opacity: 0.8;
}
.result-streak {
  margin-top: 8px;
  display: inline-block;
  padding: 3px 10px;
  background: #26e07f;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}
.result-actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
}
.result-btn {
  flex: 1;
  height: 46px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--ink);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.result-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}
.result-btn.primary { background: #00c86f; color: var(--ink); }
.result-btn.secondary { background: var(--cream); color: var(--ink); }

/* 4-Chapter Drink Menu Collection Drawer */
.stages-panel {
  width: 100%;
  max-width: 376px;
  max-height: 86%;
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 20px;
  box-shadow: var(--shadow-hard-lg);
}
.stages-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2.5px dashed rgba(23, 21, 26, 0.25);
}
.stages-title {
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: 0.05em;
}
.stages-stats {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  opacity: 0.7;
  margin-top: 2px;
}
.stages-chapters {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 2px;
}
.chapter-block-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}
.chapter-pill {
  padding: 2px 7px;
  color: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}
.chapter-name-jp {
  font-weight: 900;
  font-size: 13px;
}
.chapter-name-en {
  font-family: var(--font-mono);
  font-size: 9px;
  opacity: 0.6;
}
.stages-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.stage-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 9px 10px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s ease;
}
.stage-tile:active { transform: translate(2px, 2px); }
.stage-tile.current {
  outline: 3px solid #ff3b30;
  outline-offset: -5px;
}
.stage-tile-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}
.stage-tile-jp {
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 900;
  line-height: 1.15;
}
.stage-tile-meta {
  font-family: var(--font-mono);
  font-size: 9.5px;
  opacity: 0.72;
}
.stage-swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
}
.mini-hanko {
  position: absolute;
  bottom: 7px;
  right: 7px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #e6243b;
  border-radius: 5px;
  color: #e6243b;
  font-size: 11px;
  font-weight: 900;
  transform: rotate(-8deg);
  background: rgba(255, 249, 236, 0.9);
}
