  :root {
    --bg: #E7E9ED;
    --surface: #FFFFFF;
    --surface-2: #F1F2F5;
    --text: #1B1D24;
    --text-dim: #5C606E;
    --border: #D3D6DC;

    --rock: #8E8579;
    --rock-dark: #6E665C;
    --paper: #F4F1E6;
    --paper-ink: #C9C4B2;
    --scissors: #4E7F97;
    --scissors-dark: #375D70;

    --win: #2E9E6A;
    --lose: #D64545;
    --tie: #C68A1F;

    --accent: #E07A3E;
    --accent-ink: #7A3F1A;

    font-family: "Space Grotesk", system-ui, sans-serif;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #191A20;
      --surface: #23242C;
      --surface-2: #2B2C36;
      --text: #F2EFE6;
      --text-dim: #A6A9B4;
      --border: #383A46;

      --rock: #A79E90;
      --rock-dark: #7C7367;
      --paper: #EFEBDD;
      --paper-ink: #B9B4A0;
      --scissors: #6FA3BB;
      --scissors-dark: #4C7E93;

      --win: #4FBE88;
      --lose: #E5675E;
      --tie: #E0A83C;

      --accent: #E68A4E;
      --accent-ink: #F4D9C3;
    }
  }

  :root[data-theme="dark"] {
    --bg: #191A20;
    --surface: #23242C;
    --surface-2: #2B2C36;
    --text: #F2EFE6;
    --text-dim: #A6A9B4;
    --border: #383A46;

    --rock: #A79E90;
    --rock-dark: #7C7367;
    --paper: #EFEBDD;
    --paper-ink: #B9B4A0;
    --scissors: #6FA3BB;
    --scissors-dark: #4C7E93;

    --win: #4FBE88;
    --lose: #E5675E;
    --tie: #E0A83C;

    --accent: #E68A4E;
    --accent-ink: #F4D9C3;
  }

  .history-day-header td {
  padding-top: 12px;
  padding-bottom: 4px;
  font-weight: 700;
  color: var(--text);
  border-bottom: none;
  font-size: .78rem;
}
.history-day-header:first-child td { padding-top: 0; }

.history-day-header { cursor: pointer; user-select: none; }

  .history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.history-header .history-title { margin: 0; }
.history-clear {
  padding: 4px 12px;
  font-size: .72rem;
}

    .history-panel {
  position: fixed;
  top: 50%;
  right: 24px;
  transform: translateY(-50%);
  width: 260px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  font-size: .82rem;
}

.history-title {
  margin: 0 0 10px;
  font-family: "Fraunces", serif;
  font-style: italic;
  font-size: 1.05rem;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
}
.history-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.history-table td {
  padding: 6px 4px 6px 0;
  border-bottom: 1px solid var(--border);
}
.history-table tr:last-child td { border-bottom: none; }

.history-table .win { color: var(--win); font-weight: 600; }
.history-table .lose { color: var(--lose); font-weight: 600; }
.history-table .tie { color: var(--tie); font-weight: 600; }

.topbar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  row-gap: 10px;
}
.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar-reset {
  padding: 6px 14px;
  font-size: .78rem;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .score-row {
    justify-content: space-between;
    width: 100%;
  }
}

.history-day-header td {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.day-arrow {
  font-size: 1.05rem;
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}
.history-hint {
  margin: -4px 0 10px;
  font-size: .74rem;
  color: var(--text-dim);
  font-style: italic;
}

.info-section {
  width: 100%;
  max-width: 540px;
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
.info-block {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}
.info-block summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .92rem;
  list-style: none;
}
.info-block summary::-webkit-details-marker { display: none; }
.info-block summary::after {
  content: "+";
  float: right;
  color: var(--accent);
  font-weight: 700;
}
.info-block[open] summary::after { content: "−"; }
.info-block p {
  margin: 10px 0 0;
  font-size: .85rem;
  line-height: 1.55;
  color: var(--text-dim);
}

.site-footer {
  width: 100%;
  max-width: 720px;
  padding: 20px;
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  font-size: .82rem;
}
.site-footer a {
  color: var(--text-dim);
  text-decoration: none;
}
.site-footer a:hover { color: var(--accent); text-decoration: underline; }

.doc-page {
  width: 100%;
  max-width: 640px;
  padding: 40px 20px;
  line-height: 1.65;
}
.doc-page h1 {
  font-family: "Fraunces", serif;
  font-style: italic;
  font-size: 2rem;
  margin-bottom: 4px;
}
.doc-page .back-link {
  display: inline-block;
  margin-bottom: 24px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: .88rem;
}
.doc-page .back-link:hover { color: var(--accent); }
.doc-page h2 {
  font-size: 1.15rem;
  margin-top: 28px;
}
.doc-page p, .doc-page li { color: var(--text-dim); font-size: .92rem; }
.doc-page .updated { color: var(--text-dim); font-size: .8rem; font-style: italic; margin-top: -4px; }
@media (max-width: 1000px) {
  .history-panel {
    position: static;
    top: auto;
    right: auto;
    transform: none;
    width: 100%;
    max-height: 320px;
    margin-top: 24px;
    order: 10;
  }
}

    #home {
        animation: fadeInUp .6s ease both;
    }
    @keyframes fadeInUp {
        from { opacity: 0; transform: translateY(14px); }
        to { opacity: 1; transform: translateY(0); }
    }

    #home, #game {
        transition: opacity .2s ease, transform .2s ease;
    }
    .screen-fade {
        opacity: 0;
        transform: scale(.97);
    }

    body.loading {
        overflow: hidden;
    }

  html { scroll-padding-top: env(safe-area-inset-top, 0px); height: 100%; }
  * { box-sizing: border-box; }

  body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    transition: background .3s ease;
  }

  .screen {
    width: 100%;
    max-width: 720px;
    padding: 28px 20px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
  }

  /* ---------- HOME ---------- */

  #home {
    justify-content: center;
    text-align: center;
    gap: 22px;
  }

  .material-row {
    display: flex;
    gap: 14px;
    align-items: center;
  }

  .material-row svg { width: 46px; height: 46px; }

  h1.title {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(2.4rem, 9vw, 3.6rem);
    line-height: 1.02;
    margin: 6px 0 0;
    letter-spacing: -0.01em;
  }

  h1.title .k { color: var(--rock-dark); }
  h1.title .p { color: #F4F1E6; }
  h1.title .m { color: #4E7F97; }

  .tagline {
    color: var(--text-dim);
    font-size: 1.05rem;
    max-width: 34ch;
    margin: 0;
  }

  .btn {
    font-family: "Space Grotesk", sans-serif;
    font-weight: 600;
    font-size: 1.05rem;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    padding: 16px 40px;
    background: var(--accent);
    color: #1B1D24;
    box-shadow: 0 6px 0 var(--accent-ink);
    transform: translateY(0);
    transition: transform .12s ease, box-shadow .12s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--accent-ink); }
  .btn:hover { filter: brightness(1.04); }
  .btn:focus-visible { outline: 3px solid var(--scissors); outline-offset: 3px; }

  .btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1.5px solid var(--border);
    box-shadow: none;
    padding: 10px 20px;
    font-size: .92rem;
    border-radius: 999px;
    cursor: pointer;
    font-family: "Space Grotesk", sans-serif;
    font-weight: 500;
  }
  .btn-ghost:active { transform: translateY(1px); }

  .rules-hint {
    color: var(--text-dim);
    font-size: .88rem;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 6px;
  }
  .rules-hint span { display: flex; align-items: center; gap: 6px; }

  /* ---------- GAME ---------- */

  #game { display: none; }
  #game.active { display: flex; }

  .topbar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }

  .score {
    display: flex;
    gap: 10px;
    font-size: .92rem;
    color: var(--text-dim);
    font-weight: 600;
  }
  .score b { color: var(--text); font-weight: 700; }
  .score .w b { color: var(--win); }
  .score .l b { color: var(--lose); }
  .score .t b { color: var(--tie); }

  .arena {
    width: 100%;
    margin-top: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .side {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .side-label {
    font-size: .78rem;
    letter-spacing: .04em;
    color: var(--text-dim);
    font-weight: 600;
  }

  .vs {
    font-family: "Fraunces", serif;
    font-style: italic;
    font-weight: 600;
    color: var(--text-dim);
    font-size: 1.1rem;
    flex-shrink: 0;
  }

  .icon-slot {
    width: 108px;
    height: 108px;
    border-radius: 28px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform .15s ease, border-color .15s ease, box-shadow .2s ease;
  }
  .icon-slot svg { width: 60px; height: 60px; }

  .icon-slot.shaking { animation: shake .28s ease-in-out infinite; }
  @keyframes shake {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    25% { transform: rotate(-7deg) translateY(-3px); }
    75% { transform: rotate(7deg) translateY(-3px); }
  }

  .icon-slot.win-glow { border-color: var(--win); box-shadow: 0 0 0 5px color-mix(in srgb, var(--win) 18%, transparent); }
  .icon-slot.lose-dim { opacity: .45; filter: grayscale(.4); }

  .icon-slot.pop { animation: pop .38s cubic-bezier(.2,1.4,.4,1); }
  @keyframes pop {
    0% { transform: scale(.5); }
    70% { transform: scale(1.12); }
    100% { transform: scale(1); }
  }

  .placeholder-q {
    font-family: "Fraunces", serif;
    font-size: 2.2rem;
    color: var(--border);
    font-weight: 700;
  }

  .choices {
    width: 100%;
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
  }

  .choice-btn {
    width: 84px;
    height: 84px;
    border-radius: 24px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .12s ease, border-color .12s ease, background .12s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .choice-btn svg { width: 46px; height: 46px; }
  .choice-btn:hover { transform: translateY(-4px); border-color: var(--accent); }
  .choice-btn:active { transform: translateY(-1px) scale(.96); }
  .choice-btn:focus-visible { outline: 3px solid var(--scissors); outline-offset: 3px; }
  .choice-btn[disabled] { opacity: .35; cursor: default; pointer-events: none; }
  .choice-btn .label {
    display: none;
  }

  .choices-caption {
    margin-top: 12px;
    font-size: .85rem;
    color: var(--text-dim);
    text-align: center;
    min-height: 1.2em;
  }

  .countdown-text {
    margin-top: 18px;
    font-family: "Fraunces", serif;
    font-style: italic;
    font-weight: 700;
    font-size: 1.5rem;
    min-height: 2rem;
    color: var(--text);
    opacity: 0;
    transition: opacity .15s ease;
  }
  .countdown-text.show { opacity: 1; }

  /* ---------- RESULT OVERLAY ---------- */

  .result-panel {
    width: 100%;
    margin-top: 20px;
    border-radius: 22px;
    padding: 20px 22px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
  }
  .result-panel.show { display: flex; animation: rise .3s ease; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .result-title {
    font-family: "Fraunces", serif;
    font-weight: 700;
    font-style: italic;
    font-size: 1.9rem;
    margin: 0;
  }
  .result-title.win { color: var(--win); }
  .result-title.lose { color: var(--lose); }
  .result-title.tie { color: var(--tie); }

  .result-sub { color: var(--text-dim); font-size: .92rem; margin: -8px 0 0; }

  .streak-note {
    font-size: .82rem;
    color: var(--accent-ink);
    font-weight: 600;
  }

  .result-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

  .confetti-piece {
    position: fixed;
    top: -20px;
    width: 8px;
    height: 14px;
    opacity: .9;
    pointer-events: none;
    animation: fall linear forwards;
    z-index: 20;
    border-radius: 2px;
  }
  @keyframes fall {
    to { transform: translateY(110vh) rotate(540deg); opacity: 0; }
  }

  @media (prefers-reduced-motion: reduce) {
    .icon-slot.shaking { animation: none; }
    .icon-slot.pop { animation: none; }
    .result-panel.show { animation: none; }
    .confetti-piece { display: none; }
  }

  @media (max-width: 420px) {
    .icon-slot { width: 88px; height: 88px; border-radius: 22px; }
    .icon-slot svg { width: 48px; height: 48px; }
    .choice-btn { width: 72px; height: 72px; }
    .choice-btn svg { width: 38px; height: 38px; }
  }

  
/* ---------- COINS ---------- */
.coins {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .88rem;
  font-weight: 700;
  color: var(--accent);
}

/* ---------- THEMES BUTTON & MODAL ---------- */
.themes-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.themes-overlay.show { display: flex; }

.themes-modal {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 22px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
}
.themes-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.themes-modal-header h2 {
  font-family: "Fraunces", serif;
  font-style: italic;
  margin: 0;
  font-size: 1.3rem;
  color: var(--text);
}
.themes-coins-line {
  color: var(--text-dim);
  font-size: .85rem;
  margin: 4px 0 16px;
}

.theme-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.theme-item:last-child { border-bottom: none; }

.theme-swatch {
  display: flex;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.theme-swatch span { flex: 1; }

.theme-info { flex: 1; min-width: 0; }
.theme-name { font-weight: 600; font-size: .92rem; color: var(--text); }
.theme-price { font-size: .78rem; color: var(--text-dim); }

.theme-btn {
  padding: 6px 14px;
  font-size: .78rem;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ---------- UNLOCK TOAST ---------- */
.unlock-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: #1B1D24;
  font-weight: 700;
  font-size: .9rem;
  padding: 12px 22px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity .3s ease, transform .3s ease;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  pointer-events: none;
}
.unlock-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- THEME PALETTES ---------- */
:root[data-theme="retro"] {
  --bg: #0F0F23;
  --surface: #1A1A3E;
  --surface-2: #242459;
  --text: #F5F5F5;
  --text-dim: #9A9AC9;
  --border: #3D3D7A;
  --rock: #FFD400;
  --rock-dark: #B39500;
  --paper: #00E5FF;
  --paper-ink: #0099AA;
  --scissors: #FF3860;
  --scissors-dark: #B3102E;
  --win: #39FF14;
  --lose: #FF3860;
  --tie: #FFD400;
  --accent: #FF3860;
  --accent-ink: #7A0E1E;
}
[data-theme="retro"] .icon-slot,
[data-theme="retro"] .choice-btn,
[data-theme="retro"] .btn,
[data-theme="retro"] .btn-ghost,
[data-theme="retro"] .result-panel,
[data-theme="retro"] .info-block,
[data-theme="retro"] .history-panel,
[data-theme="retro"] .themes-modal,
[data-theme="retro"] .theme-swatch {
  border-radius: 4px;
}
[data-theme="retro"] .btn,
[data-theme="retro"] .btn-ghost {
  letter-spacing: .04em;
}

:root[data-theme="scifi"] {
  --bg: #05060F;
  --surface: #0D1024;
  --surface-2: #141833;
  --text: #E8F6FF;
  --text-dim: #7FA8C9;
  --border: #1F3A5F;
  --rock: #8892B0;
  --rock-dark: #4A5578;
  --paper: #E0F7FA;
  --paper-ink: #7DD3E0;
  --scissors: #FF2FD0;
  --scissors-dark: #9A0F82;
  --win: #00FFC6;
  --lose: #FF2F6B;
  --tie: #FFD166;
  --accent: #00E5FF;
  --accent-ink: #0A3A47;
}
[data-theme="scifi"] .icon-slot,
[data-theme="scifi"] .choice-btn {
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 35%, transparent);
}

:root[data-theme="gold"] {
  --bg: #0B0B0B;
  --surface: #171310;
  --surface-2: #1F1A15;
  --text: #F5E6C8;
  --text-dim: #B69B6B;
  --border: #3A2F1F;
  --rock: #8A7A53;
  --rock-dark: #5C4F32;
  --paper: #EFE1B8;
  --paper-ink: #C9AF77;
  --scissors: #D4AF37;
  --scissors-dark: #8A6D1E;
  --win: #9FBF63;
  --lose: #C0392B;
  --tie: #D4AF37;
  --accent: #D4AF37;
  --accent-ink: #4A3B12;
}
[data-theme="gold"] .title,
[data-theme="gold"] .btn {
  letter-spacing: .03em;
}

:root[data-theme="elements"] {
  --bg: #12181A;
  --surface: #1C2528;
  --surface-2: #243035;
  --text: #EAF2F0;
  --text-dim: #8FA6A0;
  --border: #31413F;
  --rock: #8B5E34;
  --rock-dark: #5C3D1F;
  --paper: #4FA8D8;
  --paper-ink: #2E6E94;
  --scissors: #E4572E;
  --scissors-dark: #9E3A16;
  --win: #4FA8D8;
  --lose: #E4572E;
  --tie: #8B5E34;
  --accent: #4FA8D8;
  --accent-ink: #1A3A4D;
}

/* ---------- CONFIRM MODAL ---------- */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 70;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.confirm-overlay.show { display: flex; }

.confirm-modal {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}
.confirm-message {
  margin: 0 0 18px;
  font-size: .95rem;
  color: var(--text);
  line-height: 1.5;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.confirm-actions .btn,
.confirm-actions .btn-ghost {
  flex: 1;
  padding: 10px 0;
}