:root {
  --bg: #0d2d0d;
  --fg: #88ff88;
  --muted: #2ea44f;
  --accent: #ffffff;
  --ui-scale: 1;
}
body.alt-theme {
  --bg: #0d1730;
  --fg: #88b6ff;
  --muted: #2f6fe0;
  --accent: #ffffff;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Space Mono", monospace, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  transition: background-color 520ms ease, color 520ms ease;
}

/* canvases */
#bg, #viz {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#bg { z-index: 0; image-rendering: pixelated; }
#viz { z-index: 1; pointer-events: none; image-rendering: pixelated; }

.menu {
  position: fixed;
  top: 0; left: 0;
  width: clamp(220px, 26vw, 340px);
  height: 100%;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  z-index: 2;
  backdrop-filter: blur(2px);
  opacity: 0;
  transform: translateY(12px) scale(var(--ui-scale));
  transform-origin: top left;
  transition: opacity 520ms cubic-bezier(.2,.7,.2,1), transform 520ms cubic-bezier(.2,.7,.2,1);
}
.menu.show {
  opacity: 1;
  transform: translateY(0) scale(var(--ui-scale));
}

.logo {
  font-weight: 800;
  letter-spacing: 0.5px;
  font-size: clamp(40px, 4vw, 72px);
  color: var(--fg);
  opacity: 0.92;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 10px;
}

.nav-item {
  position: relative;
  border: none;
  background: transparent;
  color: var(--fg);
  text-align: left;
  padding: 18px 18px 18px 16px;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  opacity: 0;
  transform: translateY(10px);
  transition: none;
}
.menu.show .nav-item {
  opacity: 1;
  transform: translateY(0);
  transition: transform 520ms cubic-bezier(.2,.7,.2,1), opacity 520ms ease;
}
.menu.show .nav .nav-item:nth-child(1) {
  transition-delay: 60ms;
}
.menu.show .nav .nav-item:nth-child(2) {
  transition-delay: 120ms;
}
.menu.show .nav .nav-item:nth-child(3) {
  transition-delay: 180ms;
}

.nav-item .label {
  position: relative;
  font-weight: 700;
  font-size: clamp(28px, 2.8vw, 40px);
  letter-spacing: 0.2px;
  transform: translateX(0);
  transition: transform 240ms cubic-bezier(.2,.8,.2,1), opacity 240ms ease;
  z-index: 2;
}
.nav-item .slit {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: rgba(255,255,255,0.06);
  z-index: 1;
  transform: translateX(-8%);
  clip-path: polygon(0 0, 0 0, 0 100%, 0 100%); /* collapsed */
  transition:
    width 420ms cubic-bezier(.2,.7,.2,1),
    transform 420ms cubic-bezier(.2,.7,.2,1),
    clip-path 420ms cubic-bezier(.2,.7,.2,1);
}
.nav-item:hover .label,
.nav-item:focus-visible .label {
  transform: translateX(8px);
  opacity: 1;
}
.nav-item:hover .slit,
.nav-item:focus-visible .slit {
  width: 100%;
  transform: translateX(0);
  /* slit-style reveal (angled leading edge) */
  clip-path: polygon(0 0, 88% 0, 80% 100%, 0 100%);
}
.nav-item:active .slit {
  background: rgba(255,255,255,0.10);
  transition-duration: 180ms;
}

.hint {
  color: #1e6b2b;
  margin-top: auto;
  opacity: 0.95;
}

#protip {
  opacity: 1;
  transition: opacity 320ms ease;
  font-size: clamp(20px, 2.2vw, 28px);
  font-family: "Press Start 2P", monospace;
  -webkit-text-stroke: 1px #b6ff00;
  text-shadow:
    1px 0 0 #b6ff00, -1px 0 0 #b6ff00, 0 1px 0 #b6ff00, 0 -1px 0 #b6ff00,
    1px 1px 0 #b6ff00, -1px 1px 0 #b6ff00, 1px -1px 0 #b6ff00, -1px -1px 0 #b6ff00;
}
#protip.hide { opacity: 0; }

/* subtle focus states for for accessibility */
.nav-item:focus-visible {
  outline: 2px solid rgba(255,255,255,0.25);
  outline-offset: 2px;
  border-radius: 6px;
}

/* small screens */
@media (max-width: 680px) {
  .menu {
    width: 100%;
    height: auto;
    padding: 18px 14px;
    gap: 16px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.4), rgba(0,0,0,0));
  }
  .nav {
    flex-direction: row;
    gap: 10px;
  }
  .nav-item { padding: 14px 14px; }
  .nav-item .slit { height: 100%; }
  .nav-item:hover .slit,
  .nav-item:focus-visible .slit {
    clip-path: polygon(0 0, 100% 0, 92% 100%, 0 100%);
  }
}

.start-screen {
  position: fixed; inset: 0; z-index: 3;
  display: grid; place-items: center;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  transition: opacity 360ms ease, visibility 360ms ease;
}
.start-screen.hidden { opacity: 0; visibility: hidden; }

.start-btn {
  font-family: inherit; font-weight: 800; letter-spacing: .4px;
  font-size: clamp(24px, 3.6vw, 50px);
  padding: clamp(16px, 2.8vw, 26px) clamp(34px, 5.2vw, 56px);
  border: none; border-radius: 0;
  background: #ffffff; color: #0b0b0b; cursor: pointer;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.85) inset, 0 6px 0 rgba(0,0,0,0.55);
  transition: background-color 120ms ease, box-shadow 120ms ease, transform 40ms ease, opacity 240ms ease;
}
.start-btn:hover { background: #e9e9e9; box-shadow: 0 0 0 2px rgba(0,0,0,0.9) inset, 0 6px 0 rgba(0,0,0,0.6); }
.start-btn:active { transform: translateY(2px); box-shadow: 0 0 0 2px rgba(0,0,0,0.9) inset, 0 3px 0 rgba(0,0,0,0.6); }
.start-btn:disabled,
.start-btn.clicked {
  opacity: 0.5;
  filter: saturate(0.85);
  cursor: default;
}

.logo, .nav-item .label, .start-btn {
  font-family: "Space Mono", monospace;
  -webkit-font-smoothing: none;
  text-rendering: optimizeSpeed;
  letter-spacing: 0;
}

.credits {
  position: fixed; inset: 0; z-index: 4; display: grid; place-items: center;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  opacity: 0; transform: translateY(8px) scale(0.96); transition: opacity 520ms cubic-bezier(.2,.7,.2,1), transform 520ms cubic-bezier(.2,.7,.2,1);
}
.credits.show { opacity: 1; transform: translateY(0) scale(1); }
.credits[hidden] { display: none; }
.credits-card {
  padding: 32px 36px; max-width: 780px; width: min(92vw, 780px);
  box-shadow: 0 0 0 4px #000 inset, 0 0 0 8px rgba(255,255,255,0.12) inset, 0 6px 0 rgba(0,0,0,0.5);
  image-rendering: pixelated; font-family: "Press Start 2P", monospace;
}
.close-btn {
  background: transparent;
  color: var(--fg);
  border: 2px solid rgba(255,255,255,0.22);
  font-family: "Space Mono", monospace;
  padding: 12px 18px;
  box-shadow: 0 0 0 4px #000 inset;
}

body.credits-open #bg,
body.credits-open #viz,
body.credits-open .menu {
  filter: blur(3px) saturate(0.85);
  transition: filter 520ms ease;
}

body.alt-theme #protip {
  -webkit-text-stroke: 1px #5fb0ff;
  text-shadow:
    1px 0 0 #5fb0ff, -1px 0 0 #5fb0ff, 0 1px 0 #5fb0ff, 0 -1px 0 #5fb0ff,
    1px 1px 0 #5fb0ff, -1px 1px 0 #5fb0ff, 1px -1px 0 #5fb0ff, -1px -1px 0 #5fb0ff;
}

.settings {
  position: fixed; inset: 0; z-index: 4; display: grid; place-items: center;
  background: rgba(26,12,0,0.55); /* was rgba(0,0,0,0.55) — slight orange tint */
  backdrop-filter: blur(3px);
  opacity: 0; transform: translateY(8px) scale(0.96);
  transition: opacity 520ms cubic-bezier(.2,.7,.2,1), transform 520ms cubic-bezier(.2,.7,.2,1);
}
.settings.show { opacity: 1; transform: translateY(0) scale(1); }
.settings[hidden] { display: none; }
.settings-card {
  padding: 28px 30px; max-width: 780px; width: min(92vw, 780px);
  box-shadow: 0 0 0 4px #000 inset, 0 0 0 8px rgba(255,165,0,0.20) inset, 0 6px 0 rgba(0,0,0,0.5);
  background:#0b0b0b; color:#fff; image-rendering: pixelated; font-family:"Press Start 2P", monospace;
}
body.settings-open #bg, body.settings-open #viz, body.settings-open .menu {
  filter: blur(3px) saturate(0.9) sepia(0.5) hue-rotate(-20deg); /* orange tint + blur */
  transition: filter 520ms ease;
}
.vol-row { display:block; margin-bottom:10px; color:#ffca7a; }

.redact {
  position: relative;
  display: inline-block;
  cursor: pointer;
}
.redact::after {
  content: "";
  position: absolute;
  inset: -2px -6px;
  background: #000;
  box-shadow: 0 0 0 4px #000 inset;
  transition: opacity 320ms ease, transform 120ms ease;
}
.redact.shake::after { animation: redact-shake 260ms ease; }
.redact.reveal::after { opacity: 0; pointer-events: none; }

/* subtle 8-bit shake */
@keyframes redact-shake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-2px); }
  40% { transform: translateX(2px); }
  60% { transform: translateX(-1px); }
  80% { transform: translateX(1px); }
  100% { transform: translateX(0); }
}

/* fade */
.fade {
  position: fixed; inset: 0; z-index: 20000;
  background: #000;
  opacity: 0; pointer-events: none;
  transition: opacity 520ms ease;
}
.fade.show { opacity: 1; pointer-events: auto; }

/* game root */
.game-root {
  position: fixed; inset: 0; z-index: 10000;
  background: #0a0a0a;
  image-rendering: pixelated;
}
.game-root .fx {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
}

.card-btn.is-atk { color:#ffb1b1; border-color:rgba(255,177,177,0.35); }
.card-btn.is-def { color:#b1ffcf; border-color:rgba(177,255,207,0.35); }
.card-btn.is-bless { color:#9fffb1; border-color:rgba(159,255,177,0.45); }
.card-btn.is-curse { color:#bda9ff; border-color:rgba(189,169,255,0.35); }

.legend { font-size:10px; opacity:.9; display:flex; gap:10px; justify-content:center; }
.legend span::before{content:"■ ";}

.bubble{position:absolute; bottom:-8px; width:6px; height:6px; background:#9fffb1; box-shadow:0 0 0 4px #000 inset; image-rendering:pixelated; opacity:.28; animation:oceanRise 4.2s linear forwards;}
@keyframes oceanRise{0%{transform:translateY(0) scale(1)} 85%{opacity:.35} 100%{transform:translateY(-110% ) scale(0.9); opacity:0}}


/* hide menu/canvases when in-game */
body.in-game .menu, body.in-game #viz, body.in-game #bg, body.in-game .start-screen, body.in-game .credits { display: none !important; }

@keyframes floatUp { 0%{transform:translateY(0);opacity:1} 100%{transform:translateY(-18px);opacity:0} }
@keyframes shakeX { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-3px)} 75%{transform:translateX(3px)} }
@keyframes flash { 0%{opacity:.35} 100%{opacity:0} }

.ghost-hit { animation: shakeX 240ms ease; }
.screen-flash { position:absolute; inset:0; background:currentColor; opacity:0; }
.screen-flash.show { animation: flash 260ms ease forwards; }

#vol {
  width: 100%; -webkit-appearance: none; background: transparent;
  image-rendering: pixelated; height: 22px;
}
#vol::-webkit-slider-runnable-track { height: 6px; background:#3a2a00; box-shadow: 0 0 0 4px #000 inset; }
#vol::-webkit-slider-thumb { -webkit-appearance:none; width:18px; height:18px; background:#ffa733; box-shadow:0 0 0 4px #000 inset; margin-top:-6px; }
#vol::-moz-range-track { height: 6px; background:#3a2a00; box-shadow: 0 0 0 4px #000 inset; }
#vol::-moz-range-thumb { width:18px; height:18px; background:#ffa733; box-shadow:0 0 0 4px #000 inset; border:none; }
#vol:focus { outline: 2px solid rgba(255,167,51,0.5); outline-offset: 2px; }

.vol-row input[type="checkbox"], .pixel-check { appearance: none; width: 18px; height: 18px; background:#111; border:2px solid rgba(255,255,255,0.22); box-shadow:0 0 0 4px #000 inset; cursor:pointer; display:inline-block; }
.vol-row input[type="checkbox"]:checked, .pixel-check:checked { background:#ffa733; border-color:#ffa733; }
.vol-row input[type="checkbox"]::after, .pixel-check::after { content:""; display:block; width:10px; height:10px; margin:1px auto 0; background:rgba(0,0,0,0.6); clip-path: polygon(10% 50%, 0 60%, 40% 100%, 100% 20%, 90% 10%, 40% 70%); opacity:0; }
.vol-row input[type="checkbox"]:checked::after, .pixel-check:checked::after { opacity:1; }

.pixel-input { width:100%; background:#111; color:#fff; border:2px solid rgba(255,255,255,0.22); box-shadow:0 0 0 4px #000 inset; padding:12px 14px; font-family:"Space Mono", monospace; font-size:18px; }
.pixel-input::placeholder { color:rgba(255,255,255,0.45); }
.pixel-input:focus { outline:2px solid rgba(255,255,255,0.35); outline-offset:2px; }
.pixel-input.big { padding:14px 16px; font-size:22px; }
.pixel-btn-lg { font-size:16px !important; padding:12px 16px !important; }

.version-badge{position:fixed; z-index:5; padding:6px 8px; color:#fff; opacity:0.55; font-family:"Space Mono", monospace; font-size:14px; text-shadow:0 2px 0 #000;}
.version-menu{top:8px; right:10px;}
.version-game{display:none; left:10px; bottom:8px;}
body.in-game .version-menu{display:none;}
body.in-game .version-game{display:block;}
