/* =========================================================
   接龍 · Klondike Solitaire
   綠絨牌桌 × 象牙紙牌 × 金色細節
   ========================================================= */

:root {
  --felt-deep: #04150f;
  --felt: #0a3027;
  --felt-light: #165c49;
  --gold: #d9b878;
  --gold-bright: #f0d9a8;
  --gold-dim: rgba(217, 184, 120, .32);
  --cream: #f4ecdc;
  --ivory: #fffdf7;
  --ink: #1f2a39;
  --red: #bf3a4c;
  --glass: rgba(5, 27, 21, .62);
  --hairline: rgba(255, 255, 255, .08);
  --font-sans: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Hiragino Sans TC", "Heiti TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Noto Serif TC", "Songti TC", "PMingLiU", "MingLiU", Georgia, "Times New Roman", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background-color: var(--felt-deep);
  background-image:
    radial-gradient(115% 90% at 50% -20%, rgba(54, 150, 118, .44), transparent 58%),
    radial-gradient(85% 62% at 50% 48%, rgba(14, 70, 55, .28), transparent 72%),
    linear-gradient(180deg, #0c3b2f 0%, #072a22 52%, #051c16 100%);
  color: var(--cream);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

/* 絨布微紋理 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, .05) .7px, transparent .7px);
  background-size: 4px 4px;
  opacity: .55;
}

/* 桌緣暗角 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 44%, rgba(0, 8, 6, .48) 100%);
}

button {
  margin: 0;
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

:focus-visible {
  outline: 2px solid rgba(240, 217, 168, .9);
  outline-offset: 3px;
}

::selection {
  background: rgba(217, 184, 120, .35);
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.suit-ico {
  display: inline-block;
  width: 1em;
  height: 1em;
  fill: currentColor;
  pointer-events: none;
}

.ico {
  width: 18px;
  height: 18px;
  display: block;
  flex: none;
}

#app {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===================== HUD ===================== */

#hud {
  position: relative;
  z-index: 30;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) clamp(14px, 2vw, 26px) 10px;
  background:
    linear-gradient(180deg, rgba(3, 20, 16, .9) 0%, rgba(3, 20, 16, .62) 65%, rgba(3, 20, 16, 0) 100%);
  border-bottom: 1px solid transparent;
  background-clip: padding-box;
}

#hud::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(217, 184, 120, .22) 20%, rgba(217, 184, 120, .28) 50%, rgba(217, 184, 120, .22) 80%, transparent);
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--gold-bright);
  border: 1px solid rgba(217, 184, 120, .42);
  background:
    radial-gradient(120% 120% at 30% 15%, rgba(240, 217, 168, .22), transparent 65%),
    rgba(217, 184, 120, .07);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 4px 14px -8px rgba(0, 0, 0, .8);
}

.brand-mark .suit-ico {
  width: 17px;
  height: 17px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .4));
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: .14em;
  line-height: 1.15;
  color: #f4e9d2;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .4);
}

.brand-sub {
  font-size: 7.5px;
  font-weight: 600;
  letter-spacing: .24em;
  color: rgba(217, 184, 120, .62);
  white-space: nowrap;
}

.stats {
  display: flex;
  align-items: stretch;
  margin-left: auto;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  min-width: 56px;
  padding: 0 14px;
  border-left: 1px solid rgba(255, 255, 255, .07);
}

.stat:first-child {
  border-left: 0;
}

.stat-label {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .18em;
  color: rgba(236, 226, 203, .62);
  white-space: nowrap;
}

.stat-value {
  font-size: 14.5px;
  font-weight: 650;
  line-height: 1.3;
  color: #f2e7d0;
  letter-spacing: .03em;
  font-variant-numeric: tabular-nums;
}

.actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .09);
  background: rgba(255, 255, 255, .045);
  color: #e7dcc4;
  transition: background .18s ease, border-color .18s ease, transform .12s ease, opacity .18s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, .1);
  border-color: rgba(217, 184, 120, .38);
}

.icon-btn:active {
  transform: scale(.94);
}

.icon-btn:disabled {
  opacity: .28;
}

.icon-btn .ico {
  width: 18px;
  height: 18px;
}

.icon-btn.small {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, .04);
}

.btn-new {
  height: 36px;
  padding: 0 14px 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 10px;
  border: 1px solid rgba(217, 184, 120, .4);
  background: linear-gradient(180deg, rgba(217, 184, 120, .2), rgba(217, 184, 120, .07));
  color: #f2e3c2;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  transition: background .18s ease, border-color .18s ease, transform .12s ease;
}

.btn-new:hover {
  background: linear-gradient(180deg, rgba(217, 184, 120, .3), rgba(217, 184, 120, .12));
  border-color: rgba(240, 217, 168, .65);
}

.btn-new:active {
  transform: scale(.96);
}

.btn-new .ico {
  width: 15px;
  height: 15px;
}

/* ===================== BOARD ===================== */

#board {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}

#board::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(75% 55% at 50% 0%, rgba(255, 255, 255, .055), transparent 65%);
}

#slots {
  position: absolute;
  inset: 0;
  z-index: 1;
}

#cardLayer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.slot {
  position: absolute;
  border-radius: calc(var(--cw, 64px) * .085);
  border: 1.5px solid rgba(240, 230, 205, .13);
  background: linear-gradient(180deg, rgba(0, 0, 0, .17), rgba(0, 0, 0, .05));
  box-shadow:
    inset 0 5px 16px rgba(0, 0, 0, .24),
    inset 0 0 0 1px rgba(255, 255, 255, .018),
    0 1px 0 rgba(255, 255, 255, .04);
  transition: border-color .22s ease, background .22s ease, box-shadow .22s ease;
}

.slot.tableau {
  border-style: dashed;
  border-color: rgba(240, 230, 205, .115);
  background: linear-gradient(180deg, rgba(0, 0, 0, .13), rgba(0, 0, 0, .02));
}

.slot .slot-mark {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  color: rgba(240, 230, 205, .17);
  pointer-events: none;
}

.slot.stock .slot-mark .suit-ico,
.slot.stock .slot-mark svg {
  width: 34%;
  height: auto;
}

.slot.stock.is-empty .slot-mark {
  opacity: 1;
}

.slot.stock.is-empty .slot-mark svg {
  opacity: .6;
}

.slot.stock.recyclable .slot-mark svg {
  opacity: 1;
  color: rgba(240, 217, 168, .55);
  filter: drop-shadow(0 0 10px rgba(217, 184, 120, .35));
  animation: recycleBreathe 2.6s ease-in-out infinite;
}

.slot.foundation .slot-mark {
  grid-template-columns: repeat(2, auto);
  grid-auto-rows: auto;
  gap: calc(var(--cw, 64px) * .085);
  place-content: center;
  color: rgba(240, 230, 205, .18);
}

.slot.foundation .slot-mark .suit-ico {
  width: calc(var(--cw, 64px) * .15);
  height: calc(var(--cw, 64px) * .15);
}

.slot .slot-k {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: calc(var(--cw, 64px) * .35);
  font-weight: 700;
  color: rgba(240, 230, 205, .06);
  pointer-events: none;
}

.slot.drop-glow {
  border-color: rgba(240, 217, 168, .85);
  background: rgba(217, 184, 120, .13);
  box-shadow:
    0 0 0 2px rgba(217, 184, 120, .28),
    0 0 28px rgba(217, 184, 120, .3),
    inset 0 5px 16px rgba(0, 0, 0, .16);
}

.slot.hint-slot {
  border-color: rgba(240, 217, 168, .9);
  box-shadow:
    0 0 0 2px rgba(217, 184, 120, .32),
    0 0 30px rgba(217, 184, 120, .36),
    inset 0 4px 14px rgba(0, 0, 0, .2);
  animation: slotPulse 1.15s ease-in-out infinite;
}

@keyframes recycleBreathe {
  0%, 100% { transform: scale(1); opacity: .75; }
  50% { transform: scale(1.06); opacity: 1; }
}

@keyframes slotPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(217, 184, 120, .4), 0 0 16px rgba(217, 184, 120, .25), inset 0 4px 14px rgba(0, 0, 0, .2); }
  50% { box-shadow: 0 0 0 2px rgba(240, 217, 168, .8), 0 0 34px rgba(217, 184, 120, .5), inset 0 4px 14px rgba(0, 0, 0, .2); }
}

/* ===================== CARDS ===================== */

.card {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw, 64px);
  height: var(--ch, 90px);
  -webkit-touch-callout: none;
  border-radius: calc(var(--cw, 64px) * .085);
  transform: translate3d(0, 0, 0);
  transition: transform .3s cubic-bezier(.22, .9, .23, 1);
  will-change: transform;
  pointer-events: auto;
  touch-action: none;
  -webkit-user-drag: none;
}

.card.is-face-up {
  cursor: grab;
}

.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform .38s cubic-bezier(.32, .8, .3, 1);
}

.card.is-face-down .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  -webkit-user-select: none;
  user-select: none;
}

.card-front {
  transform: rotateY(0deg);
  color: var(--ink);
  background:
    radial-gradient(125% 95% at 16% 0%, #ffffff 0%, #fdf9f0 42%, #f4ead7 100%);
  border: 1px solid rgba(88, 68, 38, .22);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .85) inset,
    0 2px 5px rgba(0, 0, 0, .26),
    0 9px 18px -12px rgba(0, 0, 0, .5);
}

.card.is-red {
  --ink: var(--red);
  --ink-soft: rgba(191, 58, 76, .22);
}

.card.is-black {
  --ink: #1f2a39;
  --ink-soft: rgba(31, 42, 57, .19);
}

.corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--cw, 64px) * .012);
  line-height: 1;
  color: var(--ink);
  pointer-events: none;
}

.corner-tl {
  top: 4.2%;
  left: 5.2%;
}

.corner-br {
  bottom: 4.2%;
  right: 5.2%;
  transform: rotate(180deg);
}

.corner .rank {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: calc(var(--cw, 64px) * .215);
  letter-spacing: -.035em;
  font-variant-numeric: lining-nums;
}

.corner .suit-ico {
  width: calc(var(--cw, 64px) * .152);
  height: calc(var(--cw, 64px) * .152);
}

.pips {
  position: absolute;
  inset: 19% 17%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(7, 1fr);
  align-items: center;
  justify-items: center;
  pointer-events: none;
}

.pip-slot {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.pip-slot .suit-ico {
  width: calc(var(--cw, 64px) * .172);
  height: calc(var(--cw, 64px) * .172);
}

.pip-slot.flip {
  transform: rotate(180deg);
}

.pips-ace {
  inset: 21% 24%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pips-ace .suit-ico {
  width: calc(var(--cw, 64px) * .44);
  height: calc(var(--cw, 64px) * .44);
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .65));
}

.face-art {
  position: absolute;
  inset: 13.5% 16%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--cw, 64px) * .02);
  border: 1px solid var(--ink-soft);
  border-radius: calc(var(--cw, 64px) * .035);
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(255, 255, 255, .7), transparent 65%),
    linear-gradient(180deg, rgba(244, 234, 214, .35), rgba(238, 225, 201, .18));
  pointer-events: none;
}

.face-art::before {
  content: "";
  position: absolute;
  inset: 4.5%;
  border: 1px solid var(--ink-soft);
  border-radius: inherit;
  opacity: .8;
}

.face-letter {
  position: relative;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: calc(var(--cw, 64px) * .355);
  line-height: .92;
  color: var(--ink);
}

.face-suit {
  position: relative;
  width: calc(var(--cw, 64px) * .165);
  height: calc(var(--cw, 64px) * .165);
}

.card-back {
  transform: rotateY(180deg);
  border: 1px solid rgba(5, 17, 34, .65);
  background:
    radial-gradient(95% 75% at 50% 20%, rgba(88, 140, 208, .55), transparent 62%),
    linear-gradient(155deg, #204879 0%, #16345d 55%, #0f2748 100%);
  box-shadow:
    inset 0 0 0 1px rgba(240, 215, 160, .14),
    0 2px 5px rgba(0, 0, 0, .3),
    0 9px 18px -12px rgba(0, 0, 0, .55);
}

.back-frame {
  position: absolute;
  inset: 5.5%;
  display: grid;
  place-items: center;
  border-radius: calc(var(--cw, 64px) * .05);
  border: 1px solid rgba(226, 198, 137, .42);
  background-image:
    repeating-linear-gradient(45deg, rgba(226, 198, 137, .1) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(-45deg, rgba(226, 198, 137, .1) 0 1px, transparent 1px 9px);
  box-shadow: inset 0 0 0 1px rgba(226, 198, 137, .07), inset 0 0 20px rgba(0, 0, 0, .16);
}

.back-frame::before {
  content: "";
  position: absolute;
  inset: 7.5%;
  border: 1px solid rgba(226, 198, 137, .17);
  border-radius: calc(var(--cw, 64px) * .03);
  pointer-events: none;
}

.back-medal {
  position: relative;
  z-index: 1;
  width: 52%;
  aspect-ratio: 1;
  height: auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(226, 198, 137, .55);
  background: radial-gradient(circle at 40% 28%, rgba(240, 215, 160, .26), rgba(10, 25, 48, .12) 72%);
  box-shadow:
    0 0 0 3px rgba(226, 198, 137, .08),
    0 0 0 5px rgba(226, 198, 137, .05),
    inset 0 0 14px rgba(240, 215, 160, .1);
}

.back-medal .suit-ico {
  width: 58%;
  height: 58%;
  color: #e8cb8f;
  opacity: .95;
}

.card.dragging {
  transition: none !important;
  cursor: grabbing;
}

.card.dragging .card-front,
.card.dragging .card-back {
  box-shadow:
    0 22px 42px -12px rgba(0, 0, 0, .6),
    0 7px 16px rgba(0, 0, 0, .32);
}

.card.dragging .card-inner {
  filter: brightness(1.035);
}

.card.drop-glow .card-face {
  box-shadow:
    0 0 0 2px rgba(240, 217, 168, .85),
    0 0 26px rgba(217, 184, 120, .5),
    0 2px 5px rgba(0, 0, 0, .26);
}

.card.hint-glow .card-face {
  animation: hintPulse 1.15s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% {
    box-shadow:
      0 0 0 2px rgba(240, 217, 168, .8),
      0 0 18px rgba(217, 184, 120, .4),
      0 2px 5px rgba(0, 0, 0, .26);
  }
  50% {
    box-shadow:
      0 0 0 3px rgba(255, 238, 198, 1),
      0 0 34px rgba(217, 184, 120, .78),
      0 2px 5px rgba(0, 0, 0, .26);
  }
}

.card.shake {
  animation: cardShake .38s ease;
}

@keyframes cardShake {
  0%, 100% { translate: 0 0; }
  18% { translate: -2.5px 0; }
  38% { translate: 2.5px 0; }
  58% { translate: -1.5px 0; }
  78% { translate: 1px 0; }
}

.no-anim .card,
.no-anim .card-inner {
  transition: none !important;
}

/* ===================== BUTTONS / AUTO ===================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 20px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
  transition: filter .18s ease, transform .12s ease, background .18s ease, border-color .18s ease;
}

.btn:active {
  transform: scale(.97);
}

.btn-gold {
  border: 1px solid rgba(255, 244, 216, .55);
  background: linear-gradient(180deg, #f2ddaa 0%, #e3c283 45%, #cfa55f 100%);
  color: #2c210d;
  box-shadow:
    0 10px 24px -12px rgba(217, 184, 120, .8),
    inset 0 1px 0 rgba(255, 255, 255, .65),
    0 1px 0 rgba(0, 0, 0, .2);
}

.btn-gold:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  border: 1px solid rgba(255, 255, 255, .13);
  background: rgba(255, 255, 255, .055);
  color: #eee3cc;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, .1);
  border-color: rgba(217, 184, 120, .32);
}

.btn-block {
  width: 100%;
  margin-top: 16px;
}

.btn-auto {
  position: fixed;
  right: clamp(14px, 3vw, 28px);
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 45px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 244, 216, .55);
  background: linear-gradient(180deg, #f2ddaa 0%, #dfbd7c 50%, #cfa55f 100%);
  color: #2b200d;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .05em;
  box-shadow:
    0 16px 34px -12px rgba(0, 0, 0, .7),
    0 0 0 4px rgba(217, 184, 120, .09),
    inset 0 1px 0 rgba(255, 255, 255, .6);
  animation: autoRise .42s cubic-bezier(.2, .9, .3, 1.15);
}

.btn-auto[hidden] {
  display: none;
}

.btn-auto:hover {
  filter: brightness(1.05);
}

.btn-auto:active {
  transform: scale(.96);
}

.btn-auto .ico {
  width: 17px;
  height: 17px;
}

.btn-auto.busy {
  opacity: .65;
  pointer-events: none;
}

@keyframes autoRise {
  from { opacity: 0; transform: translateY(12px) scale(.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===================== TOAST ===================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  z-index: 130;
  max-width: min(86vw, 460px);
  padding: 11px 19px;
  border-radius: 999px;
  border: 1px solid rgba(217, 184, 120, .3);
  background: rgba(5, 24, 19, .93);
  color: #f1e7d3;
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
  letter-spacing: .015em;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity .22s ease, transform .24s cubic-bezier(.2, .9, .3, 1);
  pointer-events: none;
  box-shadow: 0 16px 36px -16px rgba(0, 0, 0, .75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ===================== MODALS ===================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top, 0px)) 18px max(18px, env(safe-area-inset-bottom, 0px));
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(1, 10, 7, .66);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .26s ease;
}

.modal.open .modal-backdrop {
  opacity: 1;
}

.modal-card {
  position: relative;
  z-index: 2;
  width: min(100%, 462px);
  max-height: min(88vh, 760px);
  max-height: min(88dvh, 760px);
  overflow-y: auto;
  padding: 26px;
  border-radius: 20px;
  border: 1px solid rgba(217, 184, 120, .26);
  background:
    radial-gradient(120% 80% at 20% 0%, rgba(46, 112, 91, .22), transparent 55%),
    linear-gradient(168deg, rgba(17, 47, 38, .985) 0%, rgba(6, 24, 19, .995) 100%);
  box-shadow:
    0 50px 100px -30px rgba(0, 0, 0, .85),
    inset 0 1px 0 rgba(255, 255, 255, .07),
    inset 0 0 60px rgba(0, 0, 0, .18);
  opacity: 0;
  transform: translateY(16px) scale(.985);
  transition: opacity .28s ease, transform .34s cubic-bezier(.2, .9, .25, 1);
  scrollbar-width: thin;
  scrollbar-color: rgba(217, 184, 120, .28) transparent;
}

.modal.open .modal-card {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.modal-card::-webkit-scrollbar {
  width: 6px;
}

.modal-card::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(217, 184, 120, .24);
}

.eyebrow {
  margin: 0 0 5px;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: .28em;
  color: rgba(217, 184, 120, .68);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: .07em;
  color: #f4e9d2;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 0;
  border-top: 1px solid rgba(255, 255, 255, .065);
}

.setting-row:first-of-type {
  margin-top: 8px;
}

.setting-copy h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: #efe4ce;
  letter-spacing: .02em;
}

.setting-copy p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.65;
  color: rgba(235, 226, 208, .58);
}

.segmented {
  display: flex;
  flex: none;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(0, 0, 0, .24);
}

.segmented button {
  padding: 7px 13px;
  border-radius: 8px;
  color: rgba(238, 229, 210, .58);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  transition: color .18s ease, background .18s ease, box-shadow .18s ease;
}

.segmented button:hover {
  color: rgba(245, 236, 218, .9);
}

.segmented button.active {
  background: linear-gradient(180deg, rgba(217, 184, 120, .3), rgba(217, 184, 120, .15));
  color: #f5e9cd;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .25);
}

.switch {
  position: relative;
  flex: none;
  width: 46px;
  height: 26px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .075);
  transition: background .2s ease, border-color .2s ease;
}

.switch span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e8ddc4;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
  transition: transform .22s cubic-bezier(.2, .9, .3, 1.1), background .2s ease;
}

.switch[aria-checked="true"] {
  border-color: rgba(217, 184, 120, .55);
  background: rgba(217, 184, 120, .34);
}

.switch[aria-checked="true"] span {
  transform: translateX(20px);
  background: #f7e8c2;
}

.records {
  margin-top: 8px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .06);
  background: rgba(0, 0, 0, .17);
}

.records h3,
.rules h3 {
  margin: 0;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .19em;
  color: rgba(217, 184, 120, .7);
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 11px;
}

.record-grid div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.record-grid span {
  font-size: 10px;
  color: rgba(236, 226, 203, .56);
  letter-spacing: .03em;
}

.record-grid strong {
  font-size: 15px;
  font-weight: 650;
  color: #f1e5cc;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

.rules {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, .065);
}

.rules p {
  margin: 7px 0 0;
  font-size: 11.5px;
  line-height: 1.75;
  color: rgba(235, 226, 208, .62);
}

.rules p + p {
  margin-top: 4px;
}

.modal-hint {
  margin: 10px 0 0;
  text-align: center;
  font-size: 10.5px;
  color: rgba(235, 226, 208, .46);
  letter-spacing: .02em;
}

/* ===================== WIN ===================== */

#confetti {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.win-modal .modal-backdrop {
  z-index: 0;
}

.win-card {
  z-index: 3;
  width: min(100%, 442px);
  text-align: center;
  padding: 30px 28px 26px;
}

.win-emblem {
  position: relative;
  width: 66px;
  height: 66px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(217, 184, 120, .45);
  background:
    radial-gradient(circle at 50% 32%, rgba(240, 217, 168, .26), transparent 70%),
    rgba(217, 184, 120, .06);
  box-shadow:
    0 0 0 5px rgba(217, 184, 120, .045),
    0 0 36px rgba(217, 184, 120, .18);
}

.win-emblem .suit-ico {
  width: 30px;
  height: 30px;
  color: #eed9a6;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .4));
}

.win-emblem i {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(240, 217, 168, .8);
}

.win-emblem i:nth-child(2) { top: 6px; left: 50%; transform: translateX(-50%); }
.win-emblem i:nth-child(3) { bottom: 6px; left: 50%; transform: translateX(-50%); }
.win-emblem i:nth-child(4) { left: 6px; top: 50%; transform: translateY(-50%); }
.win-emblem i:nth-child(5) { right: 6px; top: 50%; transform: translateY(-50%); }

.win-card h2 {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: .12em;
  color: #f6ebd5;
  text-shadow: 0 2px 16px rgba(217, 184, 120, .2);
}

.win-sub {
  margin: 0;
  font-size: 12.5px;
  color: rgba(235, 226, 208, .65);
  letter-spacing: .02em;
}

.win-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 22px 0 0;
  padding: 16px 8px;
  border-top: 1px solid rgba(217, 184, 120, .18);
  border-bottom: 1px solid rgba(217, 184, 120, .18);
  background: linear-gradient(90deg, transparent, rgba(217, 184, 120, .045), transparent);
}

.win-stats div {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.win-stats span {
  font-size: 9.5px;
  letter-spacing: .16em;
  color: rgba(236, 226, 203, .43);
}

.win-stats strong {
  font-size: 19px;
  font-weight: 650;
  color: #f4e7cb;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

.win-note {
  min-height: 16px;
  margin: 12px 0 0;
  font-size: 11px;
  color: rgba(217, 184, 120, .82);
  letter-spacing: .02em;
}

.win-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 18px;
}

.win-actions .btn {
  width: 100%;
}

/* ===================== NOSCRIPT ===================== */

.noscript {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #061e18;
  color: #f4ecdc;
  font-size: 15px;
  text-align: center;
}

/* ===================== RESPONSIVE ===================== */

@media (max-width: 760px) {
  #hud {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand stats"
      "actions actions";
    gap: 6px 10px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 9px;
  }

  .brand {
    grid-area: brand;
  }

  .brand-mark {
    width: 31px;
    height: 31px;
    border-radius: 9px;
  }

  .brand-mark .suit-ico {
    width: 15px;
    height: 15px;
  }

  .brand-title {
    font-size: 19px;
  }

  .brand-sub {
    display: none;
  }

  .stats {
    grid-area: stats;
    margin: 0;
  }

  .stat {
    min-width: 46px;
    padding: 0 9px;
  }

  .stat:last-child {
    padding-right: 2px;
  }

  .stat-label {
    font-size: 8px;
    letter-spacing: .14em;
  }

  .stat-value {
    font-size: 13px;
  }

  .actions {
    grid-area: actions;
    justify-content: center;
    gap: 8px;
  }

  .btn-new {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
  }

  .btn-new span {
    display: none;
  }

  .btn-new .ico {
    width: 17px;
    height: 17px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .modal-card {
    padding: 22px 20px;
    border-radius: 18px;
  }

  .modal-head h2 {
    font-size: 24px;
  }

  .win-card {
    padding: 26px 20px 22px;
  }

  .win-card h2 {
    font-size: 28px;
  }

  .toast {
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    font-size: 12.5px;
    padding: 10px 16px;
    max-width: min(90vw, 420px);
  }

  .btn-auto {
    height: 42px;
    padding: 0 17px;
    font-size: 13px;
  }
}

@media (max-width: 380px) {
  .stat {
    min-width: 40px;
    padding: 0 7px;
  }

  .stat-value {
    font-size: 12.5px;
  }

  .actions {
    gap: 6px;
  }

  .icon-btn,
  .btn-new {
    width: 34px;
    height: 34px;
  }

  .record-grid strong {
    font-size: 14px;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  #hud {
    display: flex;
    align-items: center;
    padding-top: calc(5px + env(safe-area-inset-top, 0px));
    padding-bottom: 5px;
    gap: 10px;
  }

  .stats {
    margin-left: auto;
    margin-right: 2px;
  }

  .actions {
    justify-content: flex-end;
    gap: 6px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
  }

  .brand-title {
    font-size: 17px;
  }

  .brand-sub {
    display: none;
  }

  .stat {
    min-width: 48px;
    padding: 0 9px;
  }

  .stat-label {
    font-size: 8px;
  }

  .stat-value {
    font-size: 12.5px;
  }

  .icon-btn,
  .btn-new {
    width: 32px;
    height: 32px;
  }

  .btn-new {
    padding: 0;
    justify-content: center;
  }

  .btn-new span {
    display: none;
  }

  .btn-new .ico {
    width: 16px;
    height: 16px;
  }

  .modal-card {
    max-height: 92vh;
    max-height: 92dvh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .card-inner,
  .modal,
  .modal-card,
  .modal-backdrop,
  .toast {
    transition-duration: .01ms !important;
  }

  .card.hint-glow .card-face,
  .slot.hint-slot,
  .slot.stock.recyclable .slot-mark svg,
  .win-emblem {
    animation: none !important;
  }
}
