/* ================================================================
   Checkmate Rush — Game UI CSS
   Modern chess-game interface: dark purple shell, teal board
   ================================================================ */

/* ── Embedded fonts (subset, no network) ── */
:root {
  /* ── Palette ── */
  --c-bg:           #0d0d20;
  --c-panel:        #14142e;
  --c-panel-2:      #1a1a38;
  --c-border:       #2a2a55;
  --c-border-2:     #35356a;

  --c-teal:         #00c8dc;
  --c-teal-dim:     #009ab0;
  --c-green:        #14c998;
  --c-green-dim:    #0d9970;
  --c-gold:         #f5c518;
  --c-gold-dim:     #c49a10;
  --c-purple:       #7c3aed;
  --c-purple-dim:   #5b21b6;
  --c-red:          #ef4444;
  --c-orange:       #f97316;

  --sq-light:       #5ecfdf;
  --sq-dark:        #2eaabb;

  --c-text:         #e8e8ff;
  --c-text-dim:     #7878a8;
  --c-text-muted:   #4a4a7a;

  /* ── Shadows ── */
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.35);
  --shadow-md:   0 6px 20px rgba(0,0,0,0.5);
  --shadow-lg:   0 16px 48px rgba(0,0,0,0.65);
  --shadow-btn:  0 4px 0 rgba(0,0,0,0.4);
  --shadow-glow: 0 0 24px rgba(0,200,220,0.2);

  /* ── Sizes ── */
  --sidebar-w:    200px;
  --top-bar-h:     52px;
  --radius-sm:      8px;
  --radius-md:     14px;
  --radius-lg:     22px;
  --radius-pill:   50px;

  /* ── Font ── */
  --font: system-ui, -apple-system, 'Segoe UI', 'Cairo', Tahoma, Arial, sans-serif;

  color-scheme: dark;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-user-select: none;
  user-select: none;
}

button {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border: none;
  background: none;
  color: inherit;
}
button:focus-visible { outline: 2px solid var(--c-teal); outline-offset: 2px; }

.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;
}

/* ================================================================
   BACKGROUND LAYER
   ================================================================ */
.bg-layer {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
}

.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
}
.bg-glow-1 {
  width: 600px; height: 600px;
  top: -200px; left: -100px;
  background: radial-gradient(circle, #0084a0 0%, transparent 70%);
}
.bg-glow-2 {
  width: 500px; height: 500px;
  bottom: -150px; right: -100px;
  background: radial-gradient(circle, #5b21b6 0%, transparent 70%);
}

.bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ================================================================
   MAIN MENU SCREEN
   ================================================================ */
.start-screen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(10, 10, 22, 0.92);
  backdrop-filter: blur(14px);
}
.start-screen.is-hidden { display: none !important; }

.menu-wrap {
  width: min(440px, 100%);
  display: flex; flex-direction: column; align-items: center;
  gap: 24px;
  position: relative; z-index: 1;
}

.menu-logo-block { text-align: center; }

.menu-logo-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 20px rgba(0,200,220,0.5));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

.menu-eyebrow {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--c-teal);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  margin-bottom: 6px;
  opacity: 0.8;
}

.game-logo {
  font-size: clamp(1.9rem, 5vw, 2.8rem);
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.03em;
  text-shadow: 0 0 40px rgba(0,200,220,0.4);
  margin-bottom: 8px;
}

.menu-subtitle {
  font-size: 0.9rem;
  color: var(--c-text-dim);
  font-weight: 600;
  line-height: 1.6;
}

.menu-actions {
  width: 100%;
  display: flex; flex-direction: column; gap: 12px;
}

.menu-main-btn {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
  box-shadow: var(--shadow-btn), var(--shadow-md);
  position: relative; overflow: hidden;
}

.menu-main-btn::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, transparent 60%);
}

.btn-puzzle {
  background: linear-gradient(135deg, #14c998 0%, #0a8a6a 100%);
  border-color: rgba(20,201,152,0.4);
}
.btn-bot {
  background: linear-gradient(135deg, #7c3aed 0%, #4c1d95 100%);
  border-color: rgba(124,58,237,0.4);
}

.menu-main-btn:hover  { filter: brightness(1.1); transform: translateY(-2px); box-shadow: var(--shadow-btn), var(--shadow-lg); }
.menu-main-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.4), var(--shadow-sm); filter: brightness(0.95); }

.mmb-icon {
  font-size: 1.8rem;
  min-width: 36px;
  text-align: center;
  position: relative; z-index: 1;
}
.mmb-text {
  flex: 1;
  display: flex; flex-direction: column; align-items: flex-start;
  position: relative; z-index: 1;
}
.mmb-text strong { font-size: 1.1rem; font-weight: 800; color: #fff; }
.mmb-text small  { font-size: 0.75rem; color: rgba(255,255,255,0.7); margin-top: 2px; font-weight: 500; }
.mmb-arrow { font-size: 1.4rem; color: rgba(255,255,255,0.5); position: relative; z-index: 1; }

.menu-footer {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
}

.menu-icon-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  transition: background 0.15s ease, border-color 0.15s ease;
  min-width: 64px;
}
.menu-icon-btn:hover { background: var(--c-panel-2); border-color: var(--c-border-2); }
.menu-icon-btn:active { filter: brightness(0.9); }

.mib-icon  { font-size: 1.4rem; }
.mib-label { font-size: 0.68rem; color: var(--c-text-dim); font-weight: 700; }

.menu-notice {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
  background: var(--c-panel);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  color: var(--c-text-dim);
}
.menu-notice:empty { display: none; }
.menu-notice.success { border-color: var(--c-green);  color: #a7f3d0; }
.menu-notice.warning { border-color: var(--c-orange); color: #fed7aa; }
.menu-notice.info    { border-color: var(--c-teal);   color: #a5f3fc; }

/* ================================================================
   GAME SCREEN
   ================================================================ */
.game-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column;
  background: var(--c-bg);
}
.game-screen.is-hidden { display: none !important; }

/* ── TOP BAR ── */
.top-bar {
  height: var(--top-bar-h);
  min-height: var(--top-bar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  background: var(--c-panel);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
  gap: 8px;
}

.top-bar-left, .top-bar-right {
  display: flex; align-items: center; gap: 6px;
}

.top-title {
  display: flex; flex-direction: column; line-height: 1.1;
  margin: 0 6px;
}
.top-eyebrow {
  font-size: 0.62rem;
  color: var(--c-teal);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.top-game-name {
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--c-gold);
}

.tb-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--c-panel-2);
  border: 1px solid var(--c-border);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--c-text);
  transition: background 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}
.tb-btn:hover { background: var(--c-border); border-color: var(--c-border-2); }
.tb-btn:active { filter: brightness(0.85); }
.tb-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.tb-back { padding: 6px 10px; }
.tb-hint {
  background: linear-gradient(135deg, #5b21b6, #4c1d95);
  border-color: rgba(124,58,237,0.5);
  color: #fff;
}
.tb-hint:not(:disabled):hover { filter: brightness(1.1); }
.tb-label { display: none; }

/* ── PLAY AREA ── */
.play-area {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--sidebar-w);
  grid-template-rows: 1fr;
  gap: 10px;
  padding: 10px;
  overflow: hidden;
  min-height: 0;
}

/* ================================================================
   SIDEBARS
   ================================================================ */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

/* ── PLAYER CARD ── */
.player-card {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color 0.2s ease;
}

.pc-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a1a3e 0%, #0d0d25 100%);
  border: 2px solid var(--c-border-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pc-avatar-you {
  border-color: rgba(0,200,220,0.5);
  box-shadow: 0 0 14px rgba(0,200,220,0.15);
}

.pc-info {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.pc-name {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--c-text);
}
.pc-rank {
  font-size: 0.7rem;
  color: var(--c-text-dim);
  font-weight: 600;
}

.pc-pieces {
  min-height: 16px;
  font-size: 0.6rem;
  color: var(--c-text-dim);
  text-align: center;
  line-height: 1.4;
}

/* ── VS BADGE ── */
.vs-badge {
  display: flex; align-items: center; justify-content: center;
  padding: 4px 0;
}
.vs-text {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-purple) 0%, var(--c-purple-dim) 100%);
  border: 2px solid rgba(124,58,237,0.5);
  font-size: 0.9rem;
  font-weight: 900;
  color: #fff;
  box-shadow: var(--shadow-sm), 0 0 14px rgba(124,58,237,0.3);
  letter-spacing: 0.05em;
}

/* ── SIDEBAR QUICK BUTTONS ── */
.sidebar-quick-btns {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: auto;
}

.sq-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--c-text);
  transition: all 0.12s ease;
  box-shadow: var(--shadow-btn);
}
.sq-btn:hover { filter: brightness(1.1); }
.sq-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.4); }
.sq-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.sq-btn-primary {
  background: linear-gradient(135deg, var(--c-green) 0%, var(--c-green-dim) 100%);
  border-color: rgba(20,201,152,0.4);
  color: #fff;
}

.sqb-label { font-size: 0.75rem; }

/* ================================================================
   BOARD ZONE
   ================================================================ */
.board-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  overflow: hidden;
  min-width: 0;
}

.board-frame {
  --frame-pad: 8px;
  position: relative;
  padding: var(--frame-pad);
  border-radius: 18px;
  background: linear-gradient(145deg, #1a7a90 0%, #0d5a6e 50%, #0a4558 100%);
  box-shadow:
    var(--shadow-lg),
    0 0 0 1px rgba(0,200,220,0.25),
    0 0 40px rgba(0,170,200,0.15);
  width: 100%;
  /* square: limited by both width and available height */
  aspect-ratio: 1;
  max-width: min(
    calc(100% - 0px),
    calc(100vh - var(--top-bar-h) - 68px - 32px)
  );
}

/* Inner highlight */
.board-frame::before {
  content: '';
  position: absolute; inset: 4px;
  border-radius: 14px;
  border: 1px solid rgba(0,220,240,0.22);
  pointer-events: none;
  z-index: 3;
}

.chess-board {
  width: 100%; height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  border-radius: 10px;
  overflow: hidden;
  direction: ltr;
  touch-action: manipulation;
  position: relative; z-index: 2;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.4);
}

.chess-board.is-locked .sq { cursor: default; }

/* ── Squares ── */
.sq {
  aspect-ratio: 1;
  border: none;
  padding: 0;
  display: grid;
  place-items: center;
  position: relative;
  cursor: pointer;
  transition: filter 0.07s ease;
}

.sq-light { background: var(--sq-light); }
.sq-dark  { background: var(--sq-dark); }
.sq:hover { filter: brightness(1.1); }

/* ── Coordinates ── */
.coord {
  position: absolute; z-index: 4;
  font-size: clamp(0.45rem, 1vw, 0.65rem);
  font-weight: 800;
  opacity: 0.7;
  pointer-events: none;
  line-height: 1;
}
.sq-light .coord { color: #0a5060; }
.sq-dark  .coord { color: rgba(255,255,255,0.8); }
.coord-rank { left: 3px; top: 2px; }
.coord-file { right: 3px; bottom: 2px; }

/* ── Pieces ── */
.piece {
  display: flex; align-items: center; justify-content: center;
  width: 88%; height: 88%;
  user-select: none;
  pointer-events: none;
  -webkit-user-drag: none;
  transition: transform 0.1s ease;
  position: relative; z-index: 2;
}
.piece svg { pointer-events: none; -webkit-user-drag: none; }
.white-piece { filter: drop-shadow(0 3px 5px rgba(0,0,0,0.55)); }
.black-piece { filter: drop-shadow(0 3px 5px rgba(0,0,0,0.75)); }

/* ── Square States ── */
.selected {
  background-color: rgba(0, 220, 180, 0.5) !important;
  box-shadow: inset 0 0 0 3px rgba(0, 220, 180, 0.9);
}
.last-move { background-color: rgba(245, 197, 24, 0.35) !important; }

.legal-target::after {
  content: '';
  width: 30%; height: 30%;
  border-radius: 50%;
  background: rgba(0, 220, 180, 0.78);
  position: absolute;
  pointer-events: none;
  z-index: 5;
  animation: pop-in 0.15s ease-out;
}
@keyframes pop-in {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.legal-capture::after {
  content: '';
  width: 84%; height: 84%;
  border-radius: 50%;
  border: 3.5px solid rgba(239, 68, 68, 0.78);
  position: absolute;
  pointer-events: none;
  z-index: 5;
}

.hint-from { background-color: rgba(0, 180, 230, 0.42) !important; }
.hint-to   { background-color: rgba(0, 180, 230, 0.28) !important; }
.drag-over { background-color: rgba(255,255,255,0.2) !important; }

.in-check { background-color: rgba(239, 68, 68, 0.45) !important; }

/* ── Board Status Bar ── */
.board-status-bar {
  width: 100%;
  max-width: 100%;
}

.feedback {
  width: 100%;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--c-text-dim);
  text-align: center;
  min-height: 36px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1.4;
}
.feedback.correct { border-color: var(--c-green); color: #a7f3d0; }
.feedback.wrong   { border-color: var(--c-red);   color: #fca5a5; }
.feedback.info    { border-color: rgba(0,200,220,0.3); color: var(--c-text-dim); }

/* ================================================================
   RIGHT SIDEBAR
   ================================================================ */
.sidebar-right {
  padding: 4px 0;
}

/* ── Mode chip ── */
.rs-mode-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  font-size: 0.82rem;
  font-weight: 800;
}
.rs-mode-icon { font-size: 1.1rem; }
.rs-mode-text { color: var(--c-teal); }

/* ── Stats ── */
.rs-stats {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 10px;
}

.stat-row {
  display: flex; flex-direction: column; gap: 8px;
}

.stat-item {
  display: flex; justify-content: space-between; align-items: center;
  gap: 6px;
}
.stat-item-wide { flex-direction: column; align-items: flex-start; gap: 2px; }

.stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--c-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-value {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--c-text);
}
.stat-value-timer  { color: #fb7185; }
.stat-value-score  { color: var(--c-green); }
.stat-value-best   { color: var(--c-gold); }
.stat-value-puzzle { color: var(--c-teal); }

/* ── Divider ── */
.rs-divider {
  height: 1px;
  background: var(--c-border);
  margin: 2px 0;
}

/* ── Controls ── */
.rs-controls {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 10px;
}

.rs-controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.ctrl-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  background: var(--c-panel-2);
  border: 1px solid var(--c-border);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--c-text);
  transition: all 0.12s ease;
  box-shadow: var(--shadow-btn);
}
.ctrl-btn:hover { filter: brightness(1.1); border-color: var(--c-border-2); }
.ctrl-btn:active { transform: translateY(2px); box-shadow: none; }
.ctrl-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.ctrl-restart { }
.ctrl-levels  { background: linear-gradient(135deg, var(--c-green) 0%, var(--c-green-dim) 100%); border-color: rgba(20,201,152,0.4); color:#fff; }
.ctrl-sound   { }
.ctrl-lang    { }

.ctrl-icon { font-size: 1.2rem; }
.ctrl-label { font-size: 0.68rem; }

.rs-challenge-name { display: none; }

/* ================================================================
   ANIMATIONS
   ================================================================ */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-7px); }
  40%     { transform: translateX(7px); }
  60%     { transform: translateX(-5px); }
  80%     { transform: translateX(5px); }
}
.shake { animation: shake 0.32s ease-in-out; }

@keyframes pulse-glowing {
  0%,100% { box-shadow: var(--shadow-btn), 0 0 10px rgba(20,201,152,0.3); }
  50%     { box-shadow: var(--shadow-btn), 0 0 26px rgba(20,201,152,0.7); }
}
.pulse-glowing { animation: pulse-glowing 2.2s infinite; }

.hide-element { display: none !important; }

/* ================================================================
   MODALS
   ================================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 6, 18, 0.8);
  backdrop-filter: blur(8px);
  padding: 16px;
}
.modal-overlay.is-hidden { display: none !important; }

.modal-card {
  position: relative;
  background: var(--c-panel);
  border: 1px solid var(--c-border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,200,220,0.06);
  overflow: hidden;
  width: min(480px, 100%);
  animation: slide-up 0.22s ease-out;
}
@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px;
  background: var(--c-panel-2);
  border-bottom: 1px solid var(--c-border);
}
.modal-header-icon { font-size: 1.8rem; }
.modal-title {
  flex: 1;
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--c-gold);
}
.modal-close-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--c-border);
  font-size: 1rem;
  color: var(--c-text-dim);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.modal-close-btn:hover { background: var(--c-border); color: #fff; }

.modal-body {
  padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}

/* ── Difficulty Cards ── */
.diff-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.diff-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 5px;
  padding: 16px 10px;
  border-radius: var(--radius-md);
  background: var(--c-panel-2);
  border: 1px solid var(--c-border);
  text-align: center;
  box-shadow: var(--shadow-btn);
  transition: transform 0.12s ease, filter 0.12s ease, border-color 0.12s ease;
  cursor: pointer;
}
.diff-card:hover  { transform: translateY(-3px); filter: brightness(1.1); }
.diff-card:active { transform: translateY(2px); box-shadow: none; }

.easy-card   { border-top: 3px solid var(--c-green); }
.medium-card { border-top: 3px solid var(--c-gold); }
.hard-card   { border-top: 3px solid var(--c-red); }

.diff-icon   { font-size: 1.6rem; }
.diff-name   { font-size: 0.9rem; font-weight: 900; color: var(--c-text); }
.diff-rating { font-size: 0.7rem; color: var(--c-gold); font-weight: 700; }
.diff-count  { font-size: 0.65rem; color: #93c5fd; font-weight: 700; }
.diff-desc   { font-size: 0.66rem; color: var(--c-text-dim); line-height: 1.4; }
.diff-start-label {
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--c-teal);
}

.modal-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border-2);
  background: var(--c-panel-2);
  color: var(--c-text);
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--font);
  outline: none;
}
.modal-select:focus { border-color: var(--c-teal); }

.modal-count-line {
  font-size: 0.82rem;
  color: var(--c-text-dim);
  text-align: center;
  font-weight: 600;
}

/* ── Bot level grid ── */
.bot-level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.bot-level-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 8px;
  border-radius: var(--radius-md);
  background: var(--c-panel-2);
  border: 2px solid var(--c-border);
  text-align: center;
  transition: all 0.12s ease;
  box-shadow: var(--shadow-btn);
}
.bot-level-btn:hover { filter: brightness(1.1); border-color: var(--c-border-2); }
.bot-level-btn:active { transform: translateY(2px); box-shadow: none; }
.bot-level-btn.active-bot-level {
  border-color: var(--c-teal) !important;
  background: rgba(0,200,220,0.1);
}

.blvl-easy  { border-top-color: var(--c-green); }
.blvl-med   { border-top-color: var(--c-gold); }
.blvl-hard  { border-top-color: var(--c-red); }

.blvl-icon { font-size: 1.4rem; }
.bot-level-btn strong { font-size: 0.85rem; font-weight: 800; color: var(--c-text); }
.bot-level-btn small  { font-size: 0.64rem; color: var(--c-text-dim); line-height: 1.3; }

/* ── Form Sections ── */
.form-section { display: flex; flex-direction: column; gap: 8px; }
.form-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--c-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Side selector ── */
.side-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.side-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px;
  border-radius: var(--radius-md);
  background: var(--c-panel-2);
  border: 2px solid var(--c-border);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--c-text);
  transition: all 0.12s ease;
  cursor: pointer;
}
.side-btn:hover  { filter: brightness(1.1); border-color: var(--c-border-2); }
.side-btn:active { transform: translateY(2px); }

.side-piece { font-size: 1.8rem; }
.random-q   { font-size: 1.8rem; color: var(--c-red); font-weight: 900; }

.white-side  { border-color: rgba(0,200,220,0.4); }
.black-side  { border-color: rgba(75,85,99,0.6); }
.random-side { border-color: rgba(249,115,22,0.4); }

.side-btn.active-side {
  border-color: var(--c-green) !important;
  background: rgba(20,201,152,0.12);
  box-shadow: 0 0 12px rgba(20,201,152,0.2);
}

/* ── Start button ── */
.modal-start-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--c-green) 0%, var(--c-green-dim) 100%);
  border: 1px solid rgba(20,201,152,0.4);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 900;
  box-shadow: var(--shadow-btn), var(--shadow-md);
  transition: all 0.12s ease;
}
.modal-start-btn:hover  { filter: brightness(1.1); }
.modal-start-btn:active { transform: translateY(2px); box-shadow: var(--shadow-sm); }
.modal-start-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ================================================================
   RESPONSIVE LAYOUT
   ================================================================ */

/* ── Large screens: show full 3-col ── */
@media (min-width: 800px) {
  .tb-label { display: inline; }
}

/* ── Medium screens (tablet/landscape mobile) ── */
@media (max-width: 799px) {
  :root { --sidebar-w: 160px; }
  .diff-grid { grid-template-columns: 1fr; gap: 6px; }
  .diff-card { flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px; }
  .diff-card .diff-desc { display: none; }
  .diff-card .diff-start-label { margin-top: 0; margin-left: auto; }
  .bot-level-grid { grid-template-columns: 1fr; }
  .bot-level-btn { flex-direction: row; padding: 10px 12px; }
  .blvl-icon { font-size: 1.1rem; }
}

@media (max-width: 640px) {
  :root {
    --sidebar-w: 0px;
    --top-bar-h: 46px;
  }

  .play-area {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    padding: 8px;
    gap: 8px;
  }

  .sidebar-left  { display: none; }
  .sidebar-right {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    overflow: visible;
  }

  .rs-mode-chip  { flex: 1 1 40%; }
  .rs-stats      { flex: 1 1 55%; }
  .rs-divider    { display: none; }
  .rs-controls   { width: 100%; }
  .rs-controls-grid { grid-template-columns: repeat(4, 1fr); }

  .board-zone {
    grid-column: 1;
    grid-row: 1;
  }

  .board-frame {
    max-width: min(
      100%,
      calc(100vh - var(--top-bar-h) - 120px - 20px)
    );
  }

  .stat-row { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .stat-item { flex: 1 1 40%; }
  .stat-item-wide { flex: 1 1 45%; }

  .diff-grid { grid-template-columns: 1fr; }
  .side-selector { grid-template-columns: repeat(3, 1fr); }
}

/* ── Very short screens ── */
@media (max-height: 500px) {
  :root { --top-bar-h: 40px; }
  .play-area { padding: 5px; gap: 5px; }
  .board-frame {
    --frame-pad: 5px;
    border-radius: 12px;
  }
  .board-status-bar .feedback { padding: 5px 10px; font-size: 0.75rem; min-height: 28px; }
  .sidebar-left { display: none; }
  .sidebar-right {
    display: flex; flex-direction: row; flex-wrap: wrap; gap: 4px;
    grid-column: 1; grid-row: 2;
  }
  .play-area {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .rs-divider { display: none; }
  .rs-controls-grid { grid-template-columns: repeat(4,1fr); }
}
