:root {
  --bg: #dceaf5;
  --panel: #ffffff;
  --line: #b9a98c;
  --free: #e8dcc8;
  --ink: #23303a;
  --cell: 60px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
}
button {
  font: inherit; border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer;
  background: #2f6f9f; color: #fff; font-weight: 600;
}
button.sec { background: #e3e8ec; color: #2b3b47; }
button.ok { background: #2ecc71; color: #0d3a20; }
button.no { background: #e74c3c; }
button:disabled { opacity: .45; cursor: default; }
input, select, textarea {
  font: inherit; padding: 10px 12px; border: 1px solid #c3cdd6; border-radius: 10px;
  background: #fff; color: var(--ink); width: 100%;
}
h1, h2, h3 { margin: 0 0 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card { background: var(--panel); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.muted { color: #6b7c89; font-size: 14px; }

/* ---- карта ---- */
.map { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.grid { display: grid; gap: 2px; }
.cell {
  position: relative; background: var(--free); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: calc(var(--cell) * 0.34); color: #3a3226;
  border-radius: 3px; overflow: hidden; user-select: none;
}
.cell.on-dark { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.cell.on-light { color: #3a3226; }
.cell.start {
  border-width: 4px; border-color: #16232c;
  box-shadow: inset 0 0 0 2px #fff;
}
.cell > b.startmark {
  position: absolute; left: 2px; bottom: 0; z-index: 3;
  font-size: .5em; line-height: 1; color: #16232c;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}
.cell.clickable { cursor: pointer; }
.cell.claimed::before {
  content: ''; position: absolute; inset: 0; z-index: 1;
  background: repeating-linear-gradient(45deg,
    var(--claim-color) 0 6px, transparent 6px 12px);
  opacity: .8;
}
.cell.claimed .num { text-shadow: 0 0 4px #fff, 0 0 4px #fff, 0 0 6px #fff; }
.cell.claimed { outline: 2px solid var(--claim-color); outline-offset: -2px; }
.cell.my-claim { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { filter: brightness(1.25); } }
.cell > i.prev {
  position: absolute; top: 0; right: 0; z-index: 3;
  width: 30%; height: 30%; clip-path: polygon(100% 0, 0 0, 100% 100%);
}
.cell.available { box-shadow: inset 0 0 0 3px #2f6f9f; animation: blink 1.6s infinite; }
@keyframes blink { 50% { box-shadow: inset 0 0 0 3px #7fc4ff; } }
.cell.reclaimable { box-shadow: inset 0 0 0 3px #111; }
.cell span.num { position: relative; z-index: 2; }
.empty { color: #6b7c89; padding: 40px; }

/* ---- общий экран ---- */
.board-wrap { display: flex; height: 100vh; }
.board-main { flex: 1; display: flex; flex-direction: column; padding: 16px; min-width: 0; }
.board-map { flex: 1; min-height: 0; }
.board-side { width: 300px; padding: 16px 16px 16px 0; display: flex; flex-direction: column; gap: 12px; }
.timer { font-size: 64px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.timer.warn { color: #e74c3c; }
.phase { font-size: 22px; font-weight: 700; }
.score { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: #f2f6f9; }
.swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0,0,0,.25); }
.score b { margin-left: auto; font-size: 20px; }

/* ---- экран команды ---- */
.team-body { padding: 10px; max-width: 720px; margin: 0 auto; }
.team-head { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; }
.team-head .bar { display: flex; align-items: center; gap: 10px; }
.team-map { height: 52vh; }
.pill { padding: 4px 10px; border-radius: 999px; background: #fff; font-weight: 700; font-size: 14px; }
.task { background: #fff; border-radius: 14px; padding: 14px; margin-top: 10px; }
.task h3 { font-size: 17px; }
.task .text { white-space: pre-wrap; line-height: 1.45; margin: 8px 0; }
.task img { max-width: 100%; border-radius: 8px; margin: 6px 0; background: #fff; }
.imgs { display: flex; gap: 8px; flex-wrap: wrap; }
.imgs img { max-width: 30%; }
.login { max-width: 380px; margin: 15vh auto; }

/* ---- админка ---- */
.admin { max-width: 1100px; margin: 0 auto; padding: 12px; }
.sub { border-left: 5px solid #ccc; padding: 10px 12px; background: #fff; border-radius: 10px; margin-bottom: 10px; }
.sub .sol { background: #f4f8ea; border-radius: 8px; padding: 8px; margin: 8px 0; white-space: pre-wrap; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef2f5; }
.admin-map { height: 60vh; }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 6px 8px; border-bottom: 1px solid #eef1f4; }

#toast {
  position: fixed; left: 50%; bottom: -100px; transform: translateX(-50%);
  background: #23303a; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-weight: 600; transition: bottom .25s; z-index: 100; max-width: 90vw; text-align: center;
}
#toast.show { bottom: 20px; }
#toast.err { background: #c0392b; }
#toast.good { background: #1e8449; }

@media (max-width: 900px) {
  .board-wrap { flex-direction: column; height: auto; }
  .board-side { width: auto; padding: 0 16px 16px; }
  .board-map { height: 60vh; }
}
