:root {
  color-scheme: dark;
  --ink: #f7f1df;
  --muted: #aeb4c4;
  --panel: rgba(31, 36, 53, 0.92);
  --panel-2: #272d40;
  --line: rgba(255, 255, 255, 0.1);
  --gold: #e6b85d;
  --red: #e66b72;
  --green: #57bd8c;
  --felt: #174f42;
  --danger: #e36569;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: #111520; }

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% -5%, rgba(230, 184, 93, 0.18), transparent 28rem),
    radial-gradient(circle at -10% 46%, rgba(40, 126, 103, 0.2), transparent 30rem),
    linear-gradient(180deg, #171b29, #10131d 70%);
  font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

button, a { font: inherit; }

.duel-shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.duel-header, .zone-heading, .status-panel, .dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.duel-header { gap: 12px; margin-bottom: 16px; }
.duel-header > div { flex: 1; }
.kicker { margin: 0 0 2px; color: var(--gold); font-size: .68rem; font-weight: 900; letter-spacing: .16em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(1.8rem, 7vw, 2.55rem); }
h2 { margin-bottom: 0; font-size: .94rem; }

.back-link, .round-button, .close-button {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--panel-2);
  cursor: pointer;
  text-decoration: none;
  font-weight: 900;
}

.status-panel, .hand-zone, .round-history, .order-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 16px 36px rgba(0, 0, 0, .17);
}

.status-panel { gap: 12px; min-height: 78px; padding: 14px 16px; }
.status-panel > div { display: grid; gap: 3px; }
.phase-label { color: var(--gold); font-size: .72rem; font-weight: 900; letter-spacing: .08em; }
#statusText { font-size: .94rem; }
.round-badge { flex: 0 0 auto; padding: 7px 10px; border-radius: 999px; color: #111520; background: var(--gold); font-size: .72rem; font-weight: 900; }

.hand-zone { margin-top: 12px; padding: 13px; }
.zone-heading { margin-bottom: 10px; }
.zone-heading span { color: var(--muted); font-size: .78rem; }
.zone-heading b { color: var(--ink); font-size: 1rem; }
.zone-heading span.is-danger, .zone-heading span.is-danger b { color: var(--danger); }

.hand, .card-pool, .played-cards, .order-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 69px;
}

.table-zone {
  min-height: 144px;
  margin-top: 12px;
  padding: 15px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 22px;
  background:
    radial-gradient(circle at center, rgba(255,255,255,.055), transparent 60%),
    var(--felt);
  box-shadow: inset 0 0 0 4px rgba(0,0,0,.09), 0 18px 38px rgba(0,0,0,.22);
}

.pool-title { margin-bottom: 10px; color: rgba(255,255,255,.7); font-size: .75rem; font-weight: 800; text-align: center; }
.card-pool { justify-content: center; }

.playing-card {
  position: relative;
  display: grid;
  width: clamp(40px, 10.5vw, 54px);
  height: clamp(58px, 15vw, 76px);
  padding: 5px;
  place-items: center;
  border: 2px solid transparent;
  border-radius: 9px;
  color: #171b28;
  background: linear-gradient(145deg, #fffdf8, #e9e5dc);
  box-shadow: 0 5px 10px rgba(0,0,0,.22);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.1rem, 4.8vw, 1.55rem);
  font-weight: 900;
  cursor: default;
  transition: transform 130ms ease, border-color 130ms ease, opacity 130ms ease;
}

button.playing-card:not(:disabled) { cursor: pointer; }
button.playing-card:not(:disabled):active { transform: translateY(2px) scale(.96); }
.playing-card:disabled { opacity: .54; }
.playing-card.is-selectable { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(230,184,93,.18), 0 7px 14px rgba(0,0,0,.24); }
.playing-card.is-red { color: #c73e48; }
.card-corner { position: absolute; top: 4px; left: 6px; font: 800 .57rem/1 system-ui, sans-serif; }
.card-suit { position: absolute; right: 5px; bottom: 3px; font-size: .76rem; }
.empty-card { display: grid; width: 42px; height: 62px; place-items: center; border: 1px dashed rgba(255,255,255,.25); border-radius: 9px; color: rgba(255,255,255,.38); }

.battle-table { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.battle-side { display: grid; gap: 8px; justify-items: center; }
.battle-side > span { color: rgba(255,255,255,.7); font-size: .7rem; font-weight: 800; }
.played-cards { justify-content: center; }
.versus-mark { color: var(--gold); font-family: Georgia, serif; font-weight: 900; }

.order-panel { margin-top: 12px; padding: 15px; text-align: center; }
.order-panel p { margin: 6px 0 12px; color: var(--muted); font-size: .78rem; }
.order-choices { justify-content: center; }

.round-history { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 12px; padding: 10px; }
.history-item { min-width: 0; padding: 8px 3px; border-radius: 11px; color: var(--muted); background: rgba(255,255,255,.045); font-size: .66rem; font-weight: 800; text-align: center; }
.history-item strong { display: block; margin-top: 3px; color: var(--ink); font-size: .7rem; }
.history-item.player-win { background: rgba(87,189,140,.14); }
.history-item.computer-win { background: rgba(227,101,105,.13); }

.footer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 13px; }
.footer-actions .primary-button { grid-column: 1 / -1; }
.primary-button, .ghost-button { min-height: 47px; padding: 0 14px; border: 0; border-radius: 13px; cursor: pointer; font-weight: 900; }
.primary-button { color: #151821; background: var(--gold); box-shadow: 0 8px 20px rgba(230,184,93,.16); }
.ghost-button { color: var(--muted); background: var(--panel-2); }
.ghost-button:disabled { opacity: .42; cursor: default; }
.full-button { width: 100%; margin-top: 9px; }

.dialog { width: min(calc(100% - 30px), 500px); padding: 21px; border: 1px solid var(--line); border-radius: 21px; color: var(--ink); background: #202536; box-shadow: 0 28px 90px rgba(0,0,0,.5); }
.dialog::backdrop { background: rgba(5,7,12,.76); backdrop-filter: blur(4px); }
.dialog ol { padding-left: 1.25rem; color: #c6cad5; font-size: .84rem; line-height: 1.65; }
.close-button { width: 34px; height: 34px; border: 0; font-size: 1.35rem; }
.result-dialog { text-align: center; }
.result-icon { display: grid; width: 70px; height: 70px; margin: 0 auto 13px; place-items: center; border-radius: 50%; color: #151821; background: var(--gold); font: 900 2rem Georgia, serif; }
.result-eyebrow { margin-bottom: 4px; color: var(--gold); font-size: .7rem; font-weight: 900; letter-spacing: .12em; }
.result-dialog h2 { font-size: 1.45rem; }
.result-summary { margin: 10px 0 14px; color: var(--muted); line-height: 1.6; }
.result-rounds { display: grid; gap: 6px; margin-bottom: 12px; text-align: left; }
.result-round { display: flex; justify-content: space-between; padding: 9px 11px; border-radius: 10px; background: rgba(255,255,255,.045); font-size: .8rem; }

.is-hidden { display: none !important; }

@media (max-width: 390px) {
  .duel-shell { padding-inline: 10px; }
  .hand-zone { padding-inline: 9px; }
  .hand, .card-pool { gap: 5px; }
  .playing-card { width: 39px; height: 58px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
