:root {
  color-scheme: light;
  --page-1: #f5fbfa;
  --page-2: #edf6fb;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-solid: #ffffff;
  --panel-border: #d9e7ea;
  --text: #18313c;
  --muted: #607985;
  --accent: #178fa0;
  --accent-strong: #0c7180;
  --accent-soft: #dff5f4;
  --board-1: #75d8dc;
  --board-2: #3ebbc3;
  --board-3: #20909d;
  --frame: #dce9ec;
  --light-piece: #b9f7ff;
  --light-piece-mid: #4fcddd;
  --light-piece-dark: #167f92;
  --dark-piece: #4c67a8;
  --dark-piece-mid: #293f7d;
  --dark-piece-dark: #16274f;
  --danger: #d84f5f;
  --danger-soft: #fff0f1;
  --warning: #e49b22;
  --warning-soft: #fff6df;
  --success: #319c6a;
  --shadow: 0 16px 42px rgba(37, 79, 91, 0.12);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(103, 210, 210, 0.14), transparent 24rem),
    radial-gradient(circle at 92% 86%, rgba(111, 149, 213, 0.11), transparent 28rem),
    linear-gradient(145deg, var(--page-1), var(--page-2));
}

button, select, input { font: inherit; }
button { color: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 22px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: #1c5664;
  font-size: clamp(2.6rem, 7vw, 5.2rem);
  line-height: 0.9;
  letter-spacing: -0.055em;
}

.hero-copy {
  max-width: 620px;
  margin: 11px 0 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.8vw, 1.08rem);
  line-height: 1.55;
}

.header-actions,
.control-buttons,
.result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button,
.icon-button,
.dialog-close {
  border: 0;
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease, background 150ms ease, opacity 150ms ease;
}

.button:hover,
.icon-button:hover,
.dialog-close:hover { transform: translateY(-1px); }
.button:active,
.icon-button:active,
.dialog-close:active { transform: translateY(0); }
.button:disabled { cursor: not-allowed; opacity: 0.45; transform: none; }

.button {
  min-height: 44px;
  padding: 0 17px;
  border-radius: 13px;
  font-weight: 800;
}

.button-primary {
  color: #ffffff;
  background: linear-gradient(135deg, #239eab, #137e90);
  box-shadow: 0 8px 20px rgba(23, 143, 160, 0.19);
}
.button-primary:hover { filter: brightness(1.04); }

.button-secondary {
  background: #f0f6f7;
  border: 1px solid var(--panel-border);
}

.button-ghost {
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--panel-border);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: rgba(255,255,255,0.78);
  border: 1px solid var(--panel-border);
}

.control-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 20px;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.control-heading {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 1px 2px 2px;
}
.control-heading strong { font-size: 0.92rem; }
.control-heading span { color: var(--muted); font-size: 0.78rem; }

.control-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

select,
input[type="text"] {
  min-height: 44px;
  padding: 0 38px 0 13px;
  color: var(--text);
  border: 1px solid #cfdfe3;
  border-radius: 12px;
  outline: none;
  background-color: #f8fbfc;
}
select:focus,
input[type="text"]:focus { border-color: rgba(23, 143, 160, 0.72); box-shadow: 0 0 0 3px rgba(23,143,160,0.1); }

input[type="text"] {
  width: 100%;
  padding: 0 13px;
}


.time-settings {
  grid-column: span 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.time-settings label,
.time-settings select {
  min-width: 0;
}

.control-note {
  grid-column: 1 / -1;
  margin: -2px 2px 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.control-buttons {
  justify-content: flex-end;
  align-self: end;
}

.control-buttons .button { min-width: 132px; }

.game-layout {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(320px, 650px) minmax(180px, 240px);
  gap: 20px;
  align-items: center;
}

.player-panel {
  min-height: 292px;
  padding: 18px;
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
  opacity: 0.76;
  transition: opacity 180ms ease, border-color 180ms ease, transform 180ms ease;
}
.player-panel.active {
  opacity: 1;
  border-color: rgba(23, 143, 160, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 18px 45px rgba(37, 79, 91, 0.16);
}

.player-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-title-row h2 {
  margin: 2px 0 0;
  font-size: 1.22rem;
}

.player-kicker {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.timer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}

.timer-box {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #d9e7ea;
  border-radius: 12px;
  background: #f7fbfb;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.timer-box span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 750;
}

.timer-box strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.94rem;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timer-box.active-timer {
  border-color: rgba(23, 143, 160, 0.5);
  background: #edfafa;
}

.timer-box.urgent {
  border-color: rgba(216, 79, 95, 0.62);
  background: var(--danger-soft);
  animation: timer-urgent 0.8s ease-in-out infinite alternate;
}

.timer-box.urgent strong { color: #b52e40; }

.stat-row,
.warning-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
}
.stat-row { margin: 22px 0 10px; }
.warning-summary { margin: 16px 0 8px; }
.stat-row strong,
.warning-summary strong { color: var(--text); }

.capture-track {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}
.capture-slot {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px dashed #c5d7da;
  background: #f4f8f9;
}
.capture-slot.filled::after {
  content: "";
  display: block;
  width: 76%;
  height: 76%;
  margin: 12%;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 26%, #fff 0 4%, var(--slot-light) 11%, var(--slot-mid) 46%, var(--slot-dark) 100%);
  box-shadow: inset -4px -6px 8px rgba(0, 0, 0, 0.18), 0 4px 8px rgba(38, 80, 91, 0.18);
  animation: score-pop 280ms ease both;
}

.warning-track {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}
.warning-slot {
  height: 13px;
  border-radius: 999px;
  border: 1px solid #efd9a6;
  background: #fffaf0;
}
.warning-slot.filled {
  border-color: #d8901b;
  background: linear-gradient(90deg, #ffd56c, #e89b24);
  box-shadow: 0 3px 9px rgba(228, 155, 34, 0.2);
}
.player-panel.warning-flash { animation: warning-panel 520ms ease; }

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

.theme-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 15px;
  background: rgba(255,255,255,0.78);
  box-shadow: 0 8px 22px rgba(37,79,91,0.07);
}

.theme-picker-title {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.theme-options {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
}

.theme-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid #d4e2e5;
  border-radius: 11px;
  background: #f8fbfc;
  color: #405d68;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.theme-option:hover {
  transform: translateY(-1px);
  border-color: rgba(23, 143, 160, 0.45);
}

.theme-option.active,
.theme-option[aria-pressed="true"] {
  border-color: rgba(23, 143, 160, 0.7);
  background: #edfafa;
  box-shadow: 0 0 0 3px rgba(23,143,160,0.09);
}

.theme-pair {
  display: inline-flex;
  align-items: center;
  width: 31px;
}

.theme-pair i {
  display: block;
  width: 19px;
  height: 19px;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 50%;
  box-shadow: inset -3px -4px 5px rgba(0,0,0,.18), 0 2px 5px rgba(37,79,91,.16);
}

.theme-pair i + i { margin-left: -7px; }
.theme-pair-night i:first-child { background: radial-gradient(circle at 34% 26%, #fff 0 5%, #9cf4ff 12%, #41cadb 48%, #10788d 100%); }
.theme-pair-night i:last-child { background: radial-gradient(circle at 34% 26%, #7188c6 0 5%, #233b77 13%, #172953 50%, #09152f 100%); }
.theme-pair-classic i:first-child { background: radial-gradient(circle at 34% 26%, #fff 0 5%, #d9a5ff 12%, #8d48c7 48%, #4e176f 100%); }
.theme-pair-classic i:last-child { background: radial-gradient(circle at 34% 26%, #fff 0 5%, #ffad73 12%, #f16420 48%, #9a2c08 100%); }
.theme-pair-forest i:first-child { background: radial-gradient(circle at 34% 26%, #fff 0 5%, #d9ffb4 12%, #7fd36b 48%, #2e7d42 100%); }
.theme-pair-forest i:last-child { background: radial-gradient(circle at 34% 26%, #79aa91 0 5%, #286b4d 13%, #154535 50%, #08271f 100%); }

.status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  margin: 0 auto 10px;
  padding: 0 16px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: rgba(255,255,255,0.9);
  color: var(--muted);
  box-shadow: 0 8px 22px rgba(37,79,91,0.08);
}
.status-bar strong { color: var(--text); }
.status-bar.thinking { animation: breathe 1.15s ease-in-out infinite; }
.status-bar.capture { border-color: rgba(49, 156, 106, 0.55); background: #f2fbf6; }
.status-bar.error { border-color: rgba(216, 79, 95, 0.52); background: var(--danger-soft); }
.status-bar.warning { border-color: rgba(228, 155, 34, 0.62); background: var(--warning-soft); }

.turn-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(24,49,60,0.05), 0 0 12px currentColor;
}
.light-dot { color: var(--light-piece-dark); background: var(--light-piece-mid); }
.dark-dot { color: var(--dark-piece); background: var(--dark-piece); }

.board-frame {
  position: relative;
  padding: clamp(13px, 2.4vw, 24px);
  border: 1px solid #cadcdf;
  border-radius: 26px;
  background: linear-gradient(145deg, #f8fcfc, var(--frame));
  box-shadow: 0 24px 58px rgba(35, 83, 95, 0.18), inset 0 0 0 4px rgba(255,255,255,0.6);
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  aspect-ratio: 1;
  padding: clamp(10px, 2.2vw, 20px);
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at 22% 15%, rgba(255,255,255,.38), transparent 27%),
    linear-gradient(145deg, var(--board-1), var(--board-2) 58%, var(--board-3));
  box-shadow:
    inset 0 0 0 4px rgba(11, 104, 117, 0.28),
    inset 10px 12px 22px rgba(255, 255, 255, 0.18),
    inset -12px -16px 28px rgba(0, 75, 88, 0.22);
}

.board::before {
  content: "";
  position: absolute;
  inset: 8%;
  pointer-events: none;
  opacity: 0.16;
  background-size: calc(100% / 6) calc(100% / 6);
  background-image:
    linear-gradient(45deg, transparent 48%, rgba(0, 76, 87, 0.62) 49% 51%, transparent 52%),
    linear-gradient(-45deg, transparent 48%, rgba(255,255,255,0.5) 49% 51%, transparent 52%);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  isolation: isolate;
  cursor: default;
}

.cell::before {
  content: "";
  width: 44%;
  height: 44%;
  border-radius: 50%;
  background: radial-gradient(circle at 42% 35%, rgba(0, 61, 70, 0.12), rgba(2, 83, 93, 0.35) 58%, rgba(255,255,255,0.3) 70%, rgba(255,255,255,0.08));
  box-shadow: inset 2px 3px 5px rgba(0, 50, 58, 0.27), 0 1px 1px rgba(255,255,255,0.25);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.cell.interactive { cursor: pointer; }
.cell.interactive:hover::before { transform: scale(1.07); }


.cell.illegal-flash::after {
  content: "×";
  position: absolute;
  z-index: 8;
  display: grid;
  place-items: center;
  width: 42%;
  height: 42%;
  border-radius: 50%;
  color: #fff;
  background: var(--danger);
  font-size: clamp(0.9rem, 3vw, 1.5rem);
  font-weight: 900;
  box-shadow: 0 0 0 6px rgba(255,255,255,0.34);
  animation: illegal-pop 500ms ease both;
}

.piece {
  position: absolute;
  z-index: 5;
  width: 72%;
  height: 72%;
  border-radius: 50%;
  border: 0;
  pointer-events: none;
  transform: translateZ(0);
  transition: transform 150ms ease, filter 150ms ease;
  animation: piece-enter 210ms cubic-bezier(.18,.8,.3,1.25) both;
}

.piece-light,
.light-piece {
  background: radial-gradient(circle at 34% 25%, #fff 0 4%, var(--light-piece) 10%, var(--light-piece-mid) 47%, var(--light-piece-dark) 100%);
  box-shadow: inset -8px -10px 13px rgba(0, 43, 55, 0.25), inset 5px 5px 8px rgba(255,255,255,.28), 0 7px 12px rgba(0, 73, 84, .27);
}


.illegal-moving-piece {
  animation: none !important;
  transition: none !important;
  filter: drop-shadow(0 10px 12px rgba(0, 45, 58, 0.38));
  will-change: transform;
}

.cell.illegal-landing::before {
  animation: illegal-landing-pulse 360ms ease both;
}

@keyframes illegal-landing-pulse {
  0% {
    transform: scale(1);
    box-shadow: inset 2px 3px 5px rgba(0, 50, 58, 0.27);
  }
  50% {
    transform: scale(1.16);
    box-shadow:
      inset 2px 3px 5px rgba(0, 50, 58, 0.22),
      0 0 0 6px rgba(239, 101, 101, 0.34);
  }
  100% {
    transform: scale(1);
    box-shadow: inset 2px 3px 5px rgba(0, 50, 58, 0.27);
  }
}

.piece-dark,
.dark-piece {
  background: radial-gradient(circle at 34% 25%, #f7fbff 0 3%, var(--dark-piece) 10%, var(--dark-piece-mid) 47%, var(--dark-piece-dark) 100%);
  box-shadow: inset -8px -10px 13px rgba(0, 0, 0, 0.32), inset 5px 5px 8px rgba(255,255,255,.14), 0 7px 12px rgba(0, 22, 45, .34);
}

.cell.selected .piece {
  transform: scale(1.13) translateY(-4%);
  filter: drop-shadow(0 0 9px rgba(255,255,255,.8));
}
.cell.selected::before { box-shadow: inset 2px 3px 5px rgba(0, 50, 58, 0.25), 0 0 0 4px rgba(255, 236, 151, 0.9); }
.cell.last-moved .piece {
  box-shadow:
    inset -8px -10px 13px rgba(0, 43, 55, 0.25),
    inset 5px 5px 8px rgba(255,255,255,.24),
    0 7px 12px rgba(0, 73, 84, .23),
    0 0 0 3px rgba(255, 241, 163, 0.58);
}
.cell.last-moved .piece::after {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.48);
  pointer-events: none;
}
.cell.captured-flash::before { animation: captured-flash 420ms ease; }

.mini-piece {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
}

.board-help {
  min-height: 42px;
  margin-top: 10px;
  padding: 10px 14px;
  color: var(--muted);
  text-align: center;
  font-size: 0.84rem;
  line-height: 1.35;
  border: 1px solid #dce9eb;
  border-radius: 13px;
  background: rgba(255,255,255,0.7);
}
.board-help:empty { display: none; }
.board-help.warning { color: #8c5b0b; border-color: #ecd397; background: var(--warning-soft); }

.app-footer {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  padding: 16px 2px 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.rules-dialog,
.result-dialog {
  width: min(620px, calc(100% - 28px));
  padding: 0;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 30px 90px rgba(32, 66, 75, 0.28);
}
.rules-dialog::backdrop,
.result-dialog::backdrop {
  background: rgba(32, 55, 61, 0.35);
  backdrop-filter: blur(5px);
}
.rules-dialog form,
.result-dialog form { padding: clamp(20px, 4vw, 32px); }

.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}
.dialog-heading h2,
.result-dialog h2 { margin: 0; font-size: clamp(1.55rem, 4vw, 2.15rem); }
.dialog-close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #eff5f6;
  font-size: 1.6rem;
}

.rules-list {
  display: grid;
  gap: 10px;
  margin: 22px 0;
  padding-left: 1.4rem;
  color: #405d68;
  line-height: 1.48;
}
.rules-list li::marker { color: var(--accent); font-weight: 900; }

.rule-diagram {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px;
  border-radius: 16px;
  background: #f3f8f8;
}
.rule-diagram .mini-piece { width: 30px; height: 30px; }
.diagram-line { width: 18px; height: 2px; background: #9db3b9; }
.diagram-arrow { margin-left: 4px; color: var(--muted); font-size: 0.8rem; }
.dialog-confirm { width: 100%; margin-top: 18px; }

.result-dialog { text-align: center; }
.result-icon { font-size: 3rem; margin-bottom: 12px; }
.result-dialog p:not(.eyebrow) { color: var(--muted); line-height: 1.5; }
.result-actions { justify-content: center; margin-top: 22px; }

.hidden { display: none !important; }

@keyframes piece-enter { from { transform: scale(.55); opacity: 0; } }
@keyframes score-pop { from { transform: scale(.3); opacity: 0; } }
@keyframes illegal-pop { 0% { transform: scale(.25); opacity: 0; } 55% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
@keyframes captured-flash { 50% { box-shadow: inset 0 0 18px rgba(216,79,95,.7), 0 0 22px rgba(216,79,95,.55); } }
@keyframes warning-panel { 50% { border-color: #e49b22; transform: translateY(-2px) scale(1.01); } }
@keyframes breathe { 50% { opacity: .68; } }
@keyframes timer-urgent { to { transform: translateY(-1px); box-shadow: 0 0 0 3px rgba(216,79,95,.08); } }

@media (max-width: 1040px) {
  .control-panel { grid-template-columns: repeat(2, 1fr); }
  .time-settings { grid-column: 1 / -1; }
  .control-heading { grid-column: 1 / -1; }
  .control-buttons { grid-column: 1 / -1; justify-content: flex-end; }
}

@media (max-width: 980px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch;
  }
  .board-column { grid-column: 1 / -1; grid-row: 1; width: min(650px, 100%); justify-self: center; }
  .player-panel { grid-row: 2; min-height: 250px; }
}

@media (max-width: 650px) {
  .app-shell { width: min(100% - 20px, 560px); padding-top: 17px; }
  .hero { align-items: flex-start; }
  .hero-copy { max-width: 380px; }
  .header-actions { flex-direction: column-reverse; align-items: flex-end; }
  .control-panel { grid-template-columns: 1fr 1fr; }
  .control-heading { display: grid; gap: 2px; }
  .control-buttons { justify-content: stretch; }
  .control-buttons .button { flex: 1; }
  .game-layout { gap: 10px; }
  .player-panel { min-height: 230px; padding: 13px; border-radius: 17px; }
  .player-title-row { gap: 8px; }
  .mini-piece { width: 30px; height: 30px; }
  .player-title-row h2 { font-size: 1rem; }
  .timer-grid { margin-top: 12px; gap: 6px; }
  .timer-box { padding: 7px 8px; }
  .timer-box strong { font-size: .82rem; }
  .stat-row { margin: 14px 0 8px; font-size: .74rem; }
  .warning-summary { margin-top: 12px; font-size: .72rem; }
  .capture-track,
  .warning-track { gap: 5px; }
  .board-frame { border-radius: 20px; }
  .board { border-radius: 14px; }
  .theme-picker { align-items: stretch; flex-direction: column; gap: 7px; }
  .theme-picker-title { text-align: center; }
  .theme-options { width: 100%; }
  .theme-option { flex: 1 1 0; padding-inline: 7px; }
  .app-footer { flex-direction: column; gap: 4px; }
  .rule-diagram { flex-wrap: wrap; }
}

@media (max-width: 440px) {
  .control-panel { grid-template-columns: 1fr; }
  .time-settings {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .control-heading,
  .control-buttons { grid-column: auto; }
  .header-actions .button { display: none; }
  .status-bar { font-size: .82rem; }
  .theme-option { gap: 5px; font-size: .64rem; }
  .theme-pair { width: 27px; }
  .theme-pair i { width: 17px; height: 17px; }
  .player-kicker { font-size: .6rem; }
  .player-panel { min-height: 224px; }
}


/* =========================================================
   KÜRE - İSTEK ÜZERİNE KALDIRILAN ALANLAR
   Üst başlık/kurallar/ses bölümü ve alt hamle sayacı
   gizlenir. Diğer tüm özellikler korunur.
   ========================================================= */
.hero{
  display:none !important;
}

.app-footer{
  display:none !important;
}

/* Üst alan kalkınca sayfa çok boş kalmasın */
.app-shell{
  padding-top: 8px;
  padding-bottom: 16px;
}

@media (max-width: 650px){
  .app-shell{
    padding-top: 8px !important;
  }
}


/* =========================================================
   KÜRE - SATRANÇ EKRANI TARZI KOMPAKT YERLEŞİM
   Yalnızca yerleşim değişir; oyun özellikleri aynıdır.
   ========================================================= */

.app-shell{
  width:min(1280px, calc(100% - 24px)) !important;
  padding:12px 0 18px !important;
}

.compact-workspace{
  display:grid;
  grid-template-columns:minmax(0, 1.55fr) minmax(310px, .72fr);
  gap:18px;
  align-items:start;
}

.compact-game-area{
  min-width:0;
}

.compact-settings{
  min-width:0;
  position:sticky;
  top:12px;
}

/* Game area: board centered, player cards compactly below it */
.compact-game-area .game-layout{
  display:grid;
  grid-template-columns:1fr 1fr !important;
  gap:10px 12px !important;
  align-items:start !important;
}

.compact-game-area .board-column{
  grid-column:1 / -1 !important;
  grid-row:1 !important;
  width:min(690px, 100%) !important;
  justify-self:center !important;
}

.compact-game-area .player-panel{
  grid-row:2 !important;
  min-height:0 !important;
  padding:12px !important;
  border-radius:16px !important;
}

.compact-game-area #darkPanel{
  grid-column:1 !important;
}

.compact-game-area #lightPanel{
  grid-column:2 !important;
}

.compact-game-area .player-title-row{
  gap:9px;
}

.compact-game-area .mini-piece{
  width:31px;
  height:31px;
}

.compact-game-area .player-title-row h2{
  font-size:1rem;
}

.compact-game-area .player-kicker{
  font-size:.61rem;
}

.compact-game-area .timer-grid{
  margin-top:10px;
  gap:6px;
}

.compact-game-area .timer-box{
  padding:7px 8px;
  border-radius:10px;
}

.compact-game-area .timer-box span{
  font-size:.60rem;
}

.compact-game-area .timer-box strong{
  font-size:.80rem;
}

.compact-game-area .stat-row{
  margin:11px 0 6px;
  font-size:.70rem;
}

.compact-game-area .warning-summary{
  margin:9px 0 5px;
  font-size:.68rem;
}

.compact-game-area .capture-track,
.compact-game-area .warning-track{
  gap:5px;
}

/* Right-side settings card */
.compact-settings .control-panel{
  display:grid !important;
  grid-template-columns:1fr 1fr !important;
  gap:10px !important;
  margin:0 !important;
  padding:14px !important;
  border-radius:18px !important;
  align-items:end;
  background:rgba(255,255,255,.94);
}

.compact-settings .control-heading{
  grid-column:1 / -1 !important;
  display:grid !important;
  gap:2px !important;
  padding:0 1px 5px !important;
}

.compact-settings .control-heading strong{
  font-size:.92rem;
}

.compact-settings .control-heading span{
  font-size:.69rem;
}

.compact-settings .control-panel label{
  gap:5px;
  font-size:.68rem;
}

.compact-settings select,
.compact-settings input[type="text"]{
  min-height:39px;
  border-radius:10px;
  padding-left:11px;
  font-size:.78rem;
}

.compact-settings .time-settings{
  grid-column:1 / -1 !important;
  display:grid !important;
  grid-template-columns:1fr 1fr !important;
  gap:10px !important;
}

/* Theme picker becomes a compact settings block */
.compact-settings .theme-picker{
  grid-column:1 / -1;
  margin:0;
  padding:9px 10px;
  border-radius:12px;
  display:grid;
  grid-template-columns:auto 1fr;
  align-items:center;
  gap:9px;
  box-shadow:none;
}

.compact-settings .theme-picker-title{
  font-size:.68rem;
  white-space:nowrap;
}

.compact-settings .theme-options{
  justify-content:flex-end;
  gap:5px;
}

.compact-settings .theme-option{
  min-height:33px;
  padding:4px 7px;
  gap:5px;
  font-size:.62rem;
  border-radius:9px;
}

.compact-settings .theme-pair{
  width:25px;
}

.compact-settings .theme-pair i{
  width:15px;
  height:15px;
}

.compact-settings .control-buttons{
  grid-column:1 / -1 !important;
  justify-content:stretch !important;
  margin-top:1px;
}

.compact-settings .control-buttons .button{
  width:100%;
  min-height:42px;
  border-radius:11px;
}

.compact-settings .control-note{
  grid-column:1 / -1 !important;
  margin:0 1px;
  font-size:.63rem;
  text-align:center;
}

/* Board/status slightly tighter */
.compact-game-area .status-bar{
  min-height:40px;
  margin-bottom:8px;
  font-size:.82rem;
}

.compact-game-area .board-frame{
  padding:clamp(10px, 1.6vw, 18px);
  border-radius:20px;
}

.compact-game-area .board{
  padding:clamp(8px, 1.5vw, 15px);
}

/* Desktop fit refinements */
@media (max-width:1080px){
  .compact-workspace{
    grid-template-columns:minmax(0, 1.35fr) minmax(290px, .72fr);
    gap:12px;
  }

  .compact-settings .control-panel{
    padding:11px !important;
    gap:8px !important;
  }
}

/* Tablet/mobile: stack like the mobile chess layout */
@media (max-width:820px){
  .app-shell{
    width:min(100% - 14px, 680px) !important;
    padding-top:7px !important;
  }

  .compact-workspace{
    display:flex;
    flex-direction:column;
    gap:10px;
  }

  .compact-game-area{
    order:1;
    width:100%;
  }

  .compact-settings{
    order:2;
    width:100%;
    position:static;
  }

  .compact-game-area .game-layout{
    grid-template-columns:1fr 1fr !important;
  }

  .compact-settings .control-panel{
    grid-template-columns:1fr 1fr !important;
  }
}

@media (max-width:520px){
  .compact-game-area .player-panel{
    padding:10px !important;
  }

  .compact-game-area .timer-grid{
    grid-template-columns:1fr;
  }

  .compact-game-area .player-panel{
    min-width:0;
  }

  .compact-settings .control-panel{
    grid-template-columns:1fr !important;
  }

  .compact-settings .control-heading,
  .compact-settings .time-settings,
  .compact-settings .theme-picker,
  .compact-settings .control-buttons,
  .compact-settings .control-note{
    grid-column:1 !important;
  }

  .compact-settings .time-settings{
    grid-template-columns:1fr 1fr !important;
  }

  .compact-settings .theme-picker{
    grid-template-columns:1fr;
  }

  .compact-settings .theme-picker-title{
    text-align:left;
  }

  .compact-settings .theme-options{
    justify-content:stretch;
  }

  .compact-settings .theme-option{
    flex:1 1 0;
  }
}


/* =========================================================
   KÜRE - TEK DİKDÖRTGEN KOMPAKT YERLEŞİM
   Sol: oyun alanı
   Sağ: oyun ayarları + iki oyuncu kartı
   ========================================================= */

.app-shell{
  width:min(1240px, calc(100% - 20px)) !important;
  padding:10px 0 14px !important;
}

.compact-workspace{
  display:grid !important;
  grid-template-columns:minmax(0, 1.52fr) minmax(360px, .82fr) !important;
  gap:16px !important;
  align-items:stretch !important;
  padding:14px !important;
  border:1px solid var(--panel-border);
  border-radius:22px;
  background:rgba(255,255,255,.58);
  box-shadow:0 18px 48px rgba(37,79,91,.10);
  overflow:hidden;
}

.compact-game-area,
.compact-settings{
  min-width:0;
  max-width:100%;
}

.compact-game-area{
  display:flex;
  align-items:flex-start;
  justify-content:center;
}

.compact-game-area .game-layout{
  display:block !important;
  width:100%;
  max-width:700px;
}

.compact-game-area .board-column{
  width:100% !important;
  max-width:700px !important;
  margin:0 auto;
}

.compact-settings{
  position:static !important;
  display:flex;
  flex-direction:column;
  gap:12px;
  width:100%;
  align-self:stretch;
}

/* Ayarlar üstte */
.compact-settings .control-panel{
  flex:0 0 auto;
  width:100%;
  margin:0 !important;
  padding:12px !important;
  border-radius:16px !important;
  grid-template-columns:1fr 1fr !important;
  gap:8px !important;
  box-shadow:none;
}

.compact-settings .control-heading{
  padding-bottom:2px !important;
}

.compact-settings .control-heading strong{
  font-size:.86rem;
}

.compact-settings .control-heading span{
  font-size:.64rem;
}

.compact-settings .control-panel label{
  font-size:.64rem;
  gap:4px;
}

.compact-settings select,
.compact-settings input[type="text"]{
  min-height:36px;
  font-size:.73rem;
}

.compact-settings .time-settings{
  gap:8px !important;
}

.compact-settings .theme-picker{
  padding:7px 8px;
  gap:6px;
}

.compact-settings .theme-option{
  min-height:30px;
  padding:3px 6px;
  font-size:.58rem;
}

.compact-settings .control-buttons .button{
  min-height:38px;
}

.compact-settings .control-note{
  font-size:.58rem;
}

/* Oyuncular ayarların hemen altında */
.sidebar-players{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  width:100%;
  min-width:0;
}

.sidebar-players .player-panel{
  min-width:0;
  min-height:0 !important;
  padding:11px !important;
  border-radius:15px !important;
  box-shadow:none;
  overflow:hidden;
}

.sidebar-players .player-title-row{
  gap:7px;
}

.sidebar-players .mini-piece{
  width:28px;
  height:28px;
}

.sidebar-players .player-kicker{
  font-size:.54rem;
}

.sidebar-players .player-title-row h2{
  margin-top:1px;
  font-size:.88rem;
}

.sidebar-players .timer-grid{
  margin-top:8px;
  gap:5px;
}

.sidebar-players .timer-box{
  padding:6px 7px;
  border-radius:9px;
}

.sidebar-players .timer-box span{
  font-size:.52rem;
}

.sidebar-players .timer-box strong{
  font-size:.70rem;
}

.sidebar-players .stat-row{
  margin:9px 0 5px;
  font-size:.62rem;
}

.sidebar-players .warning-summary{
  margin:7px 0 4px;
  font-size:.60rem;
}

.sidebar-players .capture-track,
.sidebar-players .warning-track{
  gap:4px;
}

.sidebar-players .warning-slot{
  height:9px;
}

/* Oyuncu kartları artık oyun kolonunda yer kaplamasın */
.compact-game-area #darkPanel,
.compact-game-area #lightPanel{
  display:none !important;
}

/* Tahtayı ana dikdörtgenin içinde tut */
.compact-game-area .board-frame{
  width:100%;
  max-width:100%;
}

.compact-game-area .board{
  width:100%;
  max-width:100%;
}

/* Orta ekranlarda sağ panel biraz daralır ama taşma olmaz */
@media(max-width:1060px){
  .compact-workspace{
    grid-template-columns:minmax(0, 1.35fr) minmax(330px, .85fr) !important;
    gap:12px !important;
    padding:10px !important;
  }

  .sidebar-players{
    gap:7px;
  }
}

/* Tablet/mobil: ana dikdörtgen dikey hale gelir */
@media(max-width:820px){
  .app-shell{
    width:min(100% - 12px, 720px) !important;
  }

  .compact-workspace{
    display:flex !important;
    flex-direction:column;
    gap:10px !important;
    padding:8px !important;
    border-radius:16px;
  }

  .compact-game-area,
  .compact-settings{
    width:100%;
  }

  .compact-settings{
    gap:9px;
  }

  .compact-settings .control-panel{
    grid-template-columns:1fr 1fr !important;
  }

  .sidebar-players{
    grid-template-columns:1fr 1fr;
  }
}

@media(max-width:520px){
  .compact-settings .control-panel{
    grid-template-columns:1fr !important;
  }

  .compact-settings .control-heading,
  .compact-settings .time-settings,
  .compact-settings .theme-picker,
  .compact-settings .control-buttons,
  .compact-settings .control-note{
    grid-column:1 !important;
  }

  .compact-settings .time-settings{
    grid-template-columns:1fr 1fr !important;
  }

  .sidebar-players{
    grid-template-columns:1fr 1fr;
    gap:6px;
  }

  .sidebar-players .player-panel{
    padding:8px !important;
  }

  .sidebar-players .timer-grid{
    grid-template-columns:1fr;
  }
}


/* =========================================================
   Meti entegrasyonu
   ========================================================= */
.meti-panel{
  display:grid;
  grid-template-columns:minmax(110px, 138px) 1fr;
  gap:10px;
  align-items:center;
  padding:12px;
  border:1px solid #cfe1e4;
  border-radius:18px;
  background:linear-gradient(180deg, rgba(255,255,255,.96), rgba(244,250,250,.95));
  box-shadow:0 10px 26px rgba(47, 89, 97, 0.08);
}

.meti-visual-wrap{
  display:flex;
  justify-content:center;
  align-items:center;
}

.meti-figure{
  width:min(100%, 122px);
  height:auto;
  display:block;
  object-fit:contain;
  filter:drop-shadow(0 10px 18px rgba(74, 42, 130, .18));
}

.meti-card{
  padding:10px 12px;
  border-radius:14px;
  background:linear-gradient(180deg, #272d71, #1c225b);
  color:#fff;
}

.meti-card strong{
  display:block;
  margin-bottom:6px;
  font-size:1rem;
  line-height:1.1;
}

.meti-card p{
  margin:0;
  color:rgba(255,255,255,.92);
  font-size:.84rem;
  line-height:1.45;
}

.result-top{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:14px;
  margin-bottom:8px;
}

.result-meti-image{
  width:108px;
  height:auto;
  object-fit:contain;
  filter:drop-shadow(0 8px 14px rgba(77, 42, 130, .16));
}

.result-meti-text{
  margin-top:10px;
  padding:12px 14px;
  border-radius:14px;
  background:#f4f7fd;
  color:#334e5b !important;
  line-height:1.5;
  font-weight:600;
}

@media (max-width: 820px){
  .meti-panel{
    grid-template-columns:96px 1fr;
    gap:8px;
    padding:10px;
  }

  .meti-figure{
    width:92px;
  }
}

@media (max-width: 520px){
  .meti-panel{
    grid-template-columns:1fr;
    text-align:center;
  }

  .meti-visual-wrap{
    justify-content:center;
  }

  .meti-figure{
    width:106px;
  }

  .meti-card{
    text-align:left;
  }

  .result-top{
    flex-direction:column;
    gap:6px;
  }

  .result-meti-image{
    width:96px;
  }
}


/* --- Güncel Meti görsel entegrasyonu --- */
.meti-visual-wrap{
  min-height: 150px;
}

.meti-figure{
  max-height: 148px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.meti-card{
  position: relative;
}

.result-top-meti-only{
  justify-content: center;
  padding-top: 4px;
}

.result-top-meti-only .result-meti-image{
  width: 138px;
  max-width: min(42vw, 138px);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(112, 71, 214, .18));
}

.result-meti-text{
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.55;
  font-weight: 700;
  color: #3e5f69;
}

.result-dialog .result-top{
  min-height: auto;
}

.result-icon{
  display: none !important;
}

@media (max-width: 820px){
  .meti-figure{
    max-height: 128px;
  }
  .result-top-meti-only .result-meti-image{
    width: 112px;
    max-width: min(38vw, 112px);
  }
}

@media (max-width: 520px){
  .meti-figure{
    max-height: 104px;
  }
  .result-top-meti-only .result-meti-image{
    width: 92px;
    max-width: min(36vw, 92px);
  }
}




/* =========================================================
   MOBİL — AYARLAR ÜSTTE / GENİŞLİK STABİL
   DOM sırası JS ile değişir. display:contents kullanılmaz.
   Masaüstü kuralları etkilenmez.
   ========================================================= */
@media (max-width:820px){

  html,
  body{
    max-width:100%;
    overflow-x:hidden;
  }

  .app-shell{
    width:min(calc(100% - 12px), 720px) !important;
    max-width:100% !important;
    margin-inline:auto !important;
  }

  .compact-workspace{
    display:flex !important;
    flex-direction:column !important;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    gap:10px !important;
    padding:8px !important;
    overflow:hidden !important;
  }

  .compact-game-area,
  .compact-settings,
  .compact-workspace > .control-panel{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    flex:0 0 auto !important;
  }

  /* Mobilde workspace'e taşınan ayar paneli */
  .compact-workspace > .control-panel{
    display:grid !important;
    grid-template-columns:1fr 1fr !important;
    gap:8px !important;
    margin:0 !important;
    padding:11px !important;
    border-radius:16px !important;
    box-shadow:none !important;
    overflow:hidden !important;
  }

  .compact-workspace > .control-panel .control-heading{
    grid-column:1 / -1 !important;
    display:grid !important;
    gap:2px !important;
    padding:0 1px 3px !important;
  }

  .compact-workspace > .control-panel label,
  .compact-workspace > .control-panel select,
  .compact-workspace > .control-panel input,
  .compact-workspace > .control-panel .time-settings,
  .compact-workspace > .control-panel .theme-picker,
  .compact-workspace > .control-panel .control-buttons{
    min-width:0 !important;
    max-width:100% !important;
  }

  .compact-workspace > .control-panel select,
  .compact-workspace > .control-panel input[type="text"]{
    width:100% !important;
    min-height:36px !important;
    font-size:.73rem !important;
  }

  .compact-workspace > .control-panel .time-settings{
    grid-column:1 / -1 !important;
    display:grid !important;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr) !important;
    gap:8px !important;
    width:100% !important;
  }

  .compact-workspace > .control-panel .theme-picker{
    grid-column:1 / -1 !important;
    width:100% !important;
    margin:0 !important;
    padding:7px 8px !important;
    display:grid !important;
    grid-template-columns:auto minmax(0,1fr) !important;
    gap:6px !important;
    overflow:hidden !important;
  }

  .compact-workspace > .control-panel .theme-options{
    display:flex !important;
    width:100% !important;
    min-width:0 !important;
    gap:5px !important;
  }

  .compact-workspace > .control-panel .theme-option{
    flex:1 1 0 !important;
    min-width:0 !important;
    min-height:30px !important;
    padding:3px 5px !important;
    gap:4px !important;
    font-size:.57rem !important;
    overflow:hidden !important;
  }

  .compact-workspace > .control-panel .theme-option > span:last-child{
    overflow:hidden !important;
    text-overflow:ellipsis !important;
    white-space:nowrap !important;
  }

  .compact-workspace > .control-panel .control-buttons{
    grid-column:1 / -1 !important;
    width:100% !important;
    margin:0 !important;
  }

  .compact-workspace > .control-panel .control-buttons .button{
    width:100% !important;
    min-width:0 !important;
    min-height:38px !important;
  }

  .compact-workspace > .control-panel .control-note{
    grid-column:1 / -1 !important;
    width:100% !important;
    margin:0 !important;
    font-size:.58rem !important;
    text-align:center !important;
  }

  /* Tahta asla viewport genişliğini aşmasın */
  .compact-game-area .game-layout,
  .compact-game-area .board-column,
  .compact-game-area .board-frame,
  .compact-game-area .board{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
  }

  .compact-game-area .board-frame{
    box-sizing:border-box !important;
  }

  /* Ayarlar taşındıktan sonra kalan sağ alan: Meti + oyuncular */
  .compact-settings{
    display:flex !important;
    flex-direction:column !important;
    gap:9px !important;
    position:static !important;
  }

  .meti-panel,
  .sidebar-players{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
  }
}

@media (max-width:520px){

  .compact-workspace > .control-panel{
    grid-template-columns:1fr !important;
  }

  .compact-workspace > .control-panel .control-heading,
  .compact-workspace > .control-panel .time-settings,
  .compact-workspace > .control-panel .theme-picker,
  .compact-workspace > .control-panel .control-buttons,
  .compact-workspace > .control-panel .control-note{
    grid-column:1 !important;
  }

  /* Süreler ilk görseldeki gibi yan yana kalır */
  .compact-workspace > .control-panel .time-settings{
    grid-template-columns:minmax(0,1fr) minmax(0,1fr) !important;
  }

  .compact-workspace > .control-panel .theme-picker{
    grid-template-columns:1fr !important;
  }

  .compact-workspace > .control-panel .theme-picker-title{
    text-align:left !important;
  }

  .compact-workspace > .control-panel .theme-options{
    justify-content:stretch !important;
  }
}
