/* style.css */
@font-face {
  font-family: "KenneyFuture";
  src: url("https://assets.popchat.com/assets/kenney/ui-pack/Font/Kenney%20Future%20Narrow.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #f8f1e6;
  --muted: #aa9f92;
  --night: #090d15;
  --night-2: #101827;
  --panel: rgba(24, 33, 49, 0.9);
  --panel-border: rgba(239, 221, 191, 0.14);
  --gold: #ecba63;
  --gold-soft: #ffd98b;
  --red: #d54c4f;
  --ivory: #eee2cf;
  --board-light: #d6b486;
  --board-dark: #51372f;
  --focus: #7bd1ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --ink: #18202b;
    --muted: #6d655c;
    --night: #e8e4dc;
    --night-2: #f5f1e9;
    --panel: rgba(255, 252, 246, 0.94);
    --panel-border: rgba(59, 44, 30, 0.16);
    --board-light: #e5c69b;
    --board-dark: #65473c;
    --shadow: 0 18px 46px rgba(51, 35, 22, 0.16);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f8f1e6;
  --muted: #aa9f92;
  --night: #090d15;
  --night-2: #101827;
  --panel: rgba(24, 33, 49, 0.9);
  --panel-border: rgba(239, 221, 191, 0.14);
}

:root[data-theme="light"] {
  color-scheme: light;
  --ink: #18202b;
  --muted: #6d655c;
  --night: #e8e4dc;
  --night-2: #f5f1e9;
  --panel: rgba(255, 252, 246, 0.94);
  --panel-border: rgba(59, 44, 30, 0.16);
  --board-light: #e5c69b;
  --board-dark: #65473c;
  --shadow: 0 18px 46px rgba(51, 35, 22, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 4%, rgba(80, 116, 166, 0.26), transparent 29rem),
    radial-gradient(circle at 93% 82%, rgba(177, 89, 63, 0.18), transparent 29rem),
    var(--night);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image: linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 100% 5px;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.app-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 22px 14px 38px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 16px;
}

.eyebrow,
.label,
.rail-label {
  display: block;
  margin: 0 0 5px;
  color: var(--gold);
  font-family: KenneyFuture, Impact, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.11em;
}

.brand h1 {
  max-width: 650px;
  margin: 0;
  font-family: KenneyFuture, Impact, sans-serif;
  font-size: clamp(1.8rem, 6vw, 3.4rem);
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: 0.025em;
}

.kenney-btn {
  min-height: 46px;
  padding: 10px 18px 12px;
  border: 0;
  border-radius: 7px;
  color: #132034;
  background-color: #8ac0e7;
  background-image:
    linear-gradient(rgba(138, 192, 231, 0.54), rgba(81, 144, 188, 0.54)),
    url("https://assets.popchat.com/assets/kenney/ui-pack/PNG/Blue/Default/button_rectangle_depth_border.png");
  background-position: center;
  background-size: 100% 100%;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.55), 0 5px 0 #264c6a;
  font-family: KenneyFuture, Impact, sans-serif;
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.kenney-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.kenney-btn:active {
  transform: translateY(3px);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.5), 0 2px 0 #264c6a;
}

.kenney-btn.slim {
  min-width: 116px;
}

.opponent-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  margin-bottom: 18px;
  padding: 13px;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: linear-gradient(115deg, rgba(236, 186, 99, 0.11), transparent 45%), var(--panel);
  box-shadow: var(--shadow);
}

.portrait,
.persona-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  color: #1c1721;
  background:
    radial-gradient(circle at 34% 28%, #ffe3a4 0 8%, transparent 9%),
    linear-gradient(135deg, #f2c96f, #ae674e);
  box-shadow: 0 0 0 5px rgba(236, 186, 99, 0.1);
  font-family: KenneyFuture, Impact, sans-serif;
  font-size: 1.7rem;
}

.opponent-copy {
  min-width: 0;
}

.opponent-copy strong {
  display: block;
  font-size: 1rem;
}

.opponent-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.difficulty-badge {
  margin-left: auto;
  padding: 8px 10px;
  border: 1px solid rgba(236, 186, 99, 0.5);
  border-radius: 999px;
  color: var(--gold-soft);
  background: rgba(236, 186, 99, 0.1);
  font-family: KenneyFuture, Impact, sans-serif;
  font-size: 0.72rem;
  white-space: nowrap;
}

.arena {
  display: grid;
  gap: 20px;
}

.game-column {
  min-width: 0;
}

.status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 13px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 13px;
  background: var(--panel);
}

.status-card strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.25;
}

.new-match {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 9px 11px 11px;
  font-size: 0.7rem;
}

.board-frame {
  position: relative;
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 20px 0;
  filter: drop-shadow(0 22px 20px rgba(0, 0, 0, 0.34));
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  overflow: hidden;
  aspect-ratio: 1;
  border: 8px solid #281f25;
  border-radius: 7px;
  background: #281f25;
  box-shadow: inset 0 0 0 2px #76553f, 0 0 0 2px rgba(236, 186, 99, 0.55);
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
}

.square:disabled {
  cursor: default;
}

.light-square {
  background: var(--board-light);
}

.dark-square {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.07), transparent 40%),
    var(--board-dark);
}

.dark-square.movable::after {
  content: "";
  position: absolute;
  inset: 12%;
  border: 2px solid rgba(255, 224, 141, 0.55);
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

.square.selected {
  z-index: 1;
  box-shadow: inset 0 0 0 5px #ffe17b, inset 0 0 22px rgba(255, 224, 123, 0.9);
}

.square.target::before {
  content: "";
  position: absolute;
  z-index: 1;
  width: 24%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(253, 236, 176, 0.88);
  box-shadow: 0 0 0 5px rgba(26, 18, 22, 0.22);
}

.move-hint {
  display: none;
}

.piece {
  position: relative;
  z-index: 2;
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow:
    inset 11px 10px 9px rgba(255, 255, 255, 0.22),
    inset -10px -11px 13px rgba(0, 0, 0, 0.27),
    0 5px 5px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease;
}

.square:not(:disabled):hover .piece {
  transform: translateY(-2px) scale(1.03);
}

.red-piece {
  border: 3px solid #ff8d87;
  background:
    radial-gradient(circle at 35% 27%, #ffb3a6 0 6%, transparent 7%),
    linear-gradient(145deg, #f46c65, #a32138 70%);
}

.ivory-piece {
  border: 3px solid #fff4d9;
  background:
    radial-gradient(circle at 35% 27%, #ffffff 0 5%, transparent 7%),
    linear-gradient(145deg, #fff8e8, #b8a78e 70%);
}

.piece.king {
  border-width: 4px;
  box-shadow:
    inset 11px 10px 9px rgba(255, 255, 255, 0.3),
    inset -10px -11px 13px rgba(0, 0, 0, 0.31),
    0 0 0 3px #eec366,
    0 5px 5px rgba(0, 0, 0, 0.4);
}

.crown-mark {
  display: grid;
  place-items: center;
  width: 58%;
  height: 58%;
  margin: 18% auto;
  border: 2px solid rgba(66, 42, 30, 0.62);
  border-radius: 50%;
  color: #4a2b22;
  background: linear-gradient(#ffe7a3, #c68d36);
  box-shadow: inset 0 2px rgba(255, 255, 255, 0.55);
  font-family: KenneyFuture, Impact, sans-serif;
  font-size: clamp(0.55rem, 2vw, 1rem);
}

.board-rim {
  position: absolute;
  right: 9px;
  left: 9px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  color: var(--gold-soft);
  font-family: KenneyFuture, Impact, sans-serif;
  font-size: clamp(0.58rem, 1.8vw, 0.78rem);
  text-align: center;
}

.top-coordinates {
  top: 1px;
}

.bottom-coordinates {
  bottom: 1px;
}

.player-rail {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  width: min(100%, 720px);
  margin: 13px auto 0;
}

.piece-count {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.8rem;
}

.piece-count strong {
  color: var(--ink);
  font-size: 1.15rem;
}

.opponent-count {
  justify-content: flex-end;
}

.rail-label {
  margin: 0;
  font-size: 0.58rem;
}

.red-dot,
.ivory-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
}

.red-dot {
  background: var(--red);
  box-shadow: inset 2px 2px 2px rgba(255, 255, 255, 0.4);
}

.ivory-dot {
  background: var(--ivory);
  box-shadow: inset 2px 2px 2px white;
}

.turn-indicator {
  padding: 8px 10px;
  border: 1px solid rgba(236, 186, 99, 0.4);
  border-radius: 6px;
  color: var(--gold-soft);
  background: rgba(236, 186, 99, 0.09);
  font-family: KenneyFuture, Impact, sans-serif;
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-align: center;
  white-space: nowrap;
}

.match-panel {
  display: grid;
  gap: 13px;
}

.speech-card,
.record-card,
.move-card,
.rules-note {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.speech-card {
  padding: 17px;
}

.speech-card blockquote {
  margin: 6px 0 8px;
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 1.13rem;
  font-style: italic;
  line-height: 1.38;
}

.speech-card p {
  margin: 0;
  color: var(--gold);
  font-size: 0.78rem;
}

.record-card {
  padding: 14px;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.record-grid div {
  padding: 9px 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  text-align: center;
}

.record-grid strong {
  display: block;
  color: var(--gold-soft);
  font-size: 1.28rem;
}

.record-grid span {
  color: var(--muted);
  font-size: 0.71rem;
  text-transform: uppercase;
}

.move-card {
  overflow: hidden;
}

.move-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 9px;
}

.text-button {
  min-height: 34px;
  border: 0;
  color: #e7918e;
  background: transparent;
  font-size: 0.76rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.move-list {
  min-height: 118px;
  max-height: 240px;
  margin: 0;
  padding: 4px 14px 14px 35px;
  overflow: auto;
}

.move-list li {
  padding: 6px 0 6px 2px;
  border-bottom: 1px solid var(--panel-border);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.78rem;
}

.move-list li:last-child {
  border-bottom: 0;
}

.move-list .player-move {
  color: #f39a93;
}

.move-list .rival-move {
  color: #efe2cd;
}

.move-list .empty-ledger {
  margin-left: -18px;
  border: 0;
  list-style: none;
  font-family: inherit;
  font-size: 0.82rem;
}

.rules-note {
  padding: 14px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.42;
}

.rules-note strong {
  color: var(--gold-soft);
}

.rules-note p {
  margin: 5px 0 0;
}

dialog {
  width: min(700px, calc(100% - 24px));
  max-height: min(760px, calc(100vh - 24px));
  overflow: auto;
  border: 1px solid rgba(236, 186, 99, 0.45);
  border-radius: 18px;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(236, 186, 99, 0.16), transparent 25rem),
    var(--night-2);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}

dialog::backdrop {
  background: rgba(2, 5, 10, 0.74);
  backdrop-filter: blur(5px);
}

.settings-panel {
  padding: 20px;
}

.dialog-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.dialog-heading h2 {
  margin: 0;
  font-family: KenneyFuture, Impact, sans-serif;
  font-size: 1.7rem;
  font-weight: 400;
}

.close-button {
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 0.78rem;
}

.field-label {
  display: block;
  margin: 0 0 7px;
  color: var(--gold);
  font-family: KenneyFuture, Impact, sans-serif;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
}

select {
  width: 100%;
  min-height: 48px;
  margin-bottom: 18px;
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
}

.persona-grid {
  display: grid;
  gap: 10px;
}

.persona-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 90px;
  padding: 11px;
  border: 1px solid var(--panel-border);
  border-radius: 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.persona-choice:hover {
  border-color: rgba(236, 186, 99, 0.65);
  transform: translateY(-1px);
}

.persona-choice.chosen {
  border-color: var(--gold);
  background: rgba(236, 186, 99, 0.11);
  box-shadow: inset 0 0 0 1px rgba(236, 186, 99, 0.24);
}

.persona-choice .persona-mark {
  width: 46px;
  height: 46px;
  font-size: 1.25rem;
}

.persona-text {
  min-width: 0;
}

.persona-text strong,
.persona-text small,
.persona-text em {
  display: block;
}

.persona-text strong {
  font-size: 0.94rem;
}

.persona-text small {
  margin-top: 2px;
  color: var(--gold);
  font-size: 0.72rem;
}

.persona-text em {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-style: normal;
  line-height: 1.28;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

@keyframes pulse {
  50% {
    opacity: 0.32;
    transform: scale(0.9);
  }
}

@media (min-width: 760px) {
  .app-shell {
    padding: 32px 24px 48px;
  }

  .arena {
    grid-template-columns: minmax(0, 1fr) 350px;
    align-items: start;
  }

  .match-panel {
    position: sticky;
    top: 16px;
  }

  .persona-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 410px) {
  .topbar {
    align-items: center;
  }

  .kenney-btn.slim {
    min-width: 100px;
  }

  .brand h1 {
    font-size: 1.65rem;
  }

  .opponent-strip {
    padding: 10px;
  }

  .portrait {
    width: 48px;
    height: 48px;
    font-size: 1.35rem;
  }

  .difficulty-badge {
    display: none;
  }

  .status-card {
    align-items: flex-start;
  }

  .new-match {
    font-size: 0.61rem;
  }

  .board {
    border-width: 5px;
  }
}
