/* Park Chess: a chess table in a sunny park (or at dusk, in dark mode). */
:root {
  --grass-1: #6aa84f; --grass-2: #5b9a42; --grass-3: #7bb85c;
  --path: #d8c9a3; --path-edge: #c4b386;
  --leaf-1: #2f7a35; --leaf-2: #3f9446; --leaf-3: #276b2d; --trunk: #6b4a2b;
  --wood-1: #8a5a2e; --wood-2: #6f4421; --wood-3: #a06a38;
  --light-sq: #f0d9b5; --dark-sq: #b58863;
  --panel: rgba(255, 252, 244, .92); --panel-text: #2b2116; --panel-muted: #6e604c;
  --accent: #2f6fd6; --accent-text: #fff; --danger: #b3261e;
  --last: rgba(255, 213, 79, .55); --sel: rgba(66, 165, 245, .55); --check: rgba(229, 57, 53, .75);
  --shadow: 0 10px 30px rgba(20, 40, 10, .35);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --grass-1: #2c4f2a; --grass-2: #26462a; --grass-3: #355d31;
  --path: #6f6650; --path-edge: #5e5642;
  --leaf-1: #183f22; --leaf-2: #1f4d29; --leaf-3: #12341b; --trunk: #3e2b19;
  --panel: rgba(28, 26, 36, .9); --panel-text: #f1ece2; --panel-muted: #b7ad9b;
  --accent: #7aa7ff; --accent-text: #0d1730;
  --shadow: 0 10px 30px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  color: var(--panel-text);
  background:
    radial-gradient(circle at 20% 30%, var(--grass-3) 0 2px, transparent 3px) 0 0 / 38px 38px,
    radial-gradient(circle at 70% 80%, var(--grass-2) 0 2px, transparent 3px) 0 0 / 46px 46px,
    linear-gradient(160deg, var(--grass-1), var(--grass-2));
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; }

/* ---- scenery ---- */
.scene { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.path {
  position: absolute; left: -10%; right: -10%; top: 58%; height: 120px; transform: rotate(-8deg);
  background: var(--path); border-top: 6px solid var(--path-edge); border-bottom: 6px solid var(--path-edge);
  opacity: .85;
}
.tree { position: absolute; width: 220px; height: 220px; border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, var(--leaf-2) 0 30%, transparent 31%),
    radial-gradient(circle at 65% 40%, var(--leaf-2) 0 28%, transparent 29%),
    radial-gradient(circle at 50% 65%, var(--leaf-1) 0 34%, transparent 35%),
    radial-gradient(circle at 50% 50%, var(--leaf-3) 0 60%, transparent 61%);
  filter: drop-shadow(10px 14px 0 rgba(0, 0, 0, .18)); }
.t1 { left: -70px; top: -60px; }
.t2 { right: -80px; top: 12%; width: 260px; height: 260px; }
.t3 { left: -90px; bottom: -70px; width: 280px; height: 280px; }
.t4 { right: -60px; bottom: -90px; }
.flowers { position: absolute; width: 90px; height: 50px;
  background:
    radial-gradient(circle, #ffd54f 0 4px, transparent 5px) 0 0 / 22px 18px,
    radial-gradient(circle, #f48fb1 0 4px, transparent 5px) 11px 9px / 22px 18px; opacity: .85; }
.f1 { left: 8%; top: 46%; } .f2 { right: 10%; bottom: 16%; }

/* ---- app ---- */
.app { position: relative; height: 100%; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 10px env(safe-area-inset-bottom); }
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 4px; }
.title { display: flex; align-items: center; gap: 6px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .5); white-space: nowrap; }
.title img { width: 26px; height: 26px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5)); }
.status { flex: 1; text-align: center; background: var(--panel); border-radius: 999px; padding: 6px 14px; font-weight: 600;
  box-shadow: var(--shadow); min-height: 32px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status.alert { color: var(--danger); }
.tools { display: flex; gap: 6px; }
.icon { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--panel); color: var(--panel-text);
  box-shadow: var(--shadow); cursor: pointer; font-size: 17px; }

.layout { flex: 1; min-height: 0; display: flex; gap: 14px; justify-content: center; align-items: stretch; }
.table { display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 0; }

/* the board sizes to whatever room is left */
.frame {
  --size: min(calc(100vw - 44px), calc(100vh - 250px), 680px);
  width: calc(var(--size) + 24px); padding: 12px; border-radius: 14px;
  background: repeating-linear-gradient(95deg, var(--wood-1) 0 9px, var(--wood-2) 9px 12px, var(--wood-3) 12px 20px);
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(0, 0, 0, .25);
}
@media (min-width: 900px) { .frame { --size: min(calc(100vw - 340px), calc(100vh - 250px), 680px); } }
.board { position: relative; width: var(--size); height: var(--size); display: grid; grid-template: repeat(8, 1fr) / repeat(8, 1fr);
  border-radius: 4px; overflow: hidden; touch-action: none; user-select: none; }
.sq { position: relative; }
.sq.l { background: var(--light-sq); } .sq.d { background: var(--dark-sq); }
.sq.last::before, .sq.sel::before, .sq.check::before { content: ""; position: absolute; inset: 0; }
.sq.last::before { background: var(--last); }
.sq.sel::before { background: var(--sel); }
.sq.check::before { background: radial-gradient(circle, var(--check) 0 45%, transparent 75%); }
.sq.hint::after { content: ""; position: absolute; left: 36%; top: 36%; width: 28%; height: 28%; border-radius: 50%; background: rgba(20, 30, 10, .28); }
.sq.hint.take::after { left: 6%; top: 6%; width: 88%; height: 88%; background: none; border: 5px solid rgba(20, 30, 10, .28); box-sizing: border-box; }
.coord { position: absolute; font-size: 11px; font-weight: 700; opacity: .75; pointer-events: none; }
.coord.file { right: 3px; bottom: 1px; } .coord.rank { left: 3px; top: 1px; }
.sq.l .coord { color: var(--dark-sq); } .sq.d .coord { color: var(--light-sq); }
.piece { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.piece.mine { cursor: grab; }
.piece.slide { animation: slide .22s ease-out; }
@keyframes slide { from { transform: translate(var(--dx), var(--dy)); } to { transform: none; } }
.ghost { position: fixed; z-index: 50; pointer-events: none; transform: translate(-50%, -50%) scale(1.12); filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .35)); }
.board.dragging .piece.lifted { opacity: .25; }

/* benches = player plates */
.bench { width: calc(min(calc(100vw - 44px), calc(100vh - 250px), 680px) + 24px); display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; border-radius: 12px; min-height: 48px;
  background: repeating-linear-gradient(0deg, var(--wood-3) 0 10px, var(--wood-1) 10px 13px); color: #fff;
  box-shadow: var(--shadow); }
@media (min-width: 900px) { .bench { width: calc(min(calc(100vw - 340px), calc(100vh - 250px), 680px) + 24px); } }
.bench .who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  background: #fff; color: #333; border: 3px solid #222; }
.avatar.b { background: #222; color: #fff; border-color: #fff; }
.name { font-weight: 700; text-shadow: 0 1px 2px rgba(0, 0, 0, .55); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { font-size: 12px; opacity: .9; text-shadow: 0 1px 2px rgba(0, 0, 0, .55); }
.bench.turn { outline: 3px solid #ffe082; outline-offset: 2px; }
.captured { display: flex; flex-wrap: wrap; justify-content: flex-end; max-width: 45%; }
.captured img { width: 18px; height: 18px; margin-left: -4px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .4)); }
.empty-seat { opacity: .9; font-style: italic; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 40px; }
.btn { border: 0; border-radius: 999px; padding: 9px 18px; font-weight: 700; cursor: pointer; background: var(--panel); color: var(--panel-text); box-shadow: var(--shadow); }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.sit { border: 2px dashed rgba(255, 255, 255, .8); background: rgba(0, 0, 0, .15); color: #fff; padding: 6px 14px; border-radius: 999px; font-weight: 700; cursor: pointer; }

/* moves panel: beside the board on wide screens, a sheet on narrow ones */
.moves { width: 230px; background: var(--panel); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 80px); }
.moves h2 { font-size: 14px; margin: 0 0 6px; text-transform: uppercase; letter-spacing: .06em; color: var(--panel-muted); }
.moves ol { margin: 0; padding: 0 0 0 2.2em; overflow: auto; flex: 1; font-variant-numeric: tabular-nums; }
.moves li { padding: 1px 0; }
.moves li span { display: inline-block; min-width: 4.2em; }
.credit { font-size: 11px; color: var(--panel-muted); margin: 8px 0 0; }
.credit a { color: inherit; }
#toggleMoves { display: none; }
@media (max-width: 899px) {
  #toggleMoves { display: block; }
  .moves { position: fixed; right: 10px; top: 56px; bottom: 10px; z-index: 20; display: none; }
  .moves.open { display: flex; }
}

.promo { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: grid; place-items: center; z-index: 60; }
.promo-card { background: var(--panel); border-radius: 16px; padding: 12px 16px; box-shadow: var(--shadow); text-align: center; }
.promo-card p { margin: 0 0 6px; font-weight: 700; }
.promo-row { display: flex; gap: 8px; }
.promo-row button { width: 64px; height: 64px; border-radius: 12px; border: 0; background: var(--light-sq); cursor: pointer; }
.promo-row img { width: 100%; height: 100%; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--panel); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); z-index: 70; font-weight: 600; max-width: 90vw; }
.notice { max-width: 520px; margin: 0; text-align: center; background: var(--panel); border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow); font-size: 14px; }
.notice a { color: var(--accent); }
[hidden] { display: none !important; }
@media (max-width: 480px) { .title .label { display: none; } }
