:root {
  --bayou: #0E3B35;     /* тёмная болотная зелень: шапка, таймер */
  --croc: #1F7A5C;      /* основной зелёный */
  --croc-d: #165A44;
  --sun: #FFC53D;       /* акцент: плитки слова, подсветка */
  --sun-d: #E0A516;
  --mist: #EAF2EE;      /* фон страницы */
  --ink: #10231F;
  --muted: #5B7570;
  --line: #CFE0D8;
  --coral: #E4572E;
  --sky: #2F7FD1;
  --r: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--mist); color: var(--ink);
  font-family: 'Rubik', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px; line-height: 1.45;
}
[v-cloak] { display: none; }
h1, h2 { margin: 0 0 .5em; line-height: 1.15; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
h2 { font-size: 1.15rem; }
p { margin: 0 0 .8em; }
a { color: var(--croc); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); font-weight: 400; }
.hint { color: var(--muted); font-size: .9rem; }
.hint.light { color: rgba(255,255,255,.8); }
.lead { font-size: 1.05rem; color: var(--muted); }

/* ---------- шапка ---------- */
.top {
  background: var(--bayou); color: #fff; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 10px clamp(12px, 3vw, 28px);
  padding-top: max(10px, env(safe-area-inset-top));
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.45rem; letter-spacing: .2px; }
.brand small { color: var(--sun); font-weight: 500; font-size: .95rem; margin-left: 8px; }
.mainnav { display: flex; flex-wrap: wrap; gap: 6px; }
.nav-btn {
  background: transparent; border: 0; color: #d9ebe4; padding: .45em .8em; border-radius: 999px; cursor: pointer; font-weight: 500;
}
.nav-btn:hover { background: rgba(255,255,255,.1); }
.nav-btn.on { background: var(--sun); color: var(--ink); }
.nav-btn.quiet { opacity: .75; }
/* зубастая кромка под шапкой */
.teeth {
  height: 12px;
  background:
    linear-gradient(135deg, var(--bayou) 25%, transparent 25%) -7px 0 / 14px 12px,
    linear-gradient(225deg, var(--bayou) 25%, transparent 25%) -7px 0 / 14px 12px;
}
.banner { margin: 0; background: var(--coral); color: #fff; text-align: center; padding: 6px 12px; font-size: .9rem; }

main { max-width: 1280px; margin: 0 auto; padding: 18px clamp(10px, 3vw, 28px) 48px; }

/* ---------- базовые элементы ---------- */
.card { background: #fff; border: 1.5px solid var(--line); border-radius: var(--r); padding: 16px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; justify-content: center; }
.row.between { justify-content: space-between; flex-wrap: wrap; }
.input {
  width: 100%; padding: .55em .75em; border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
}
textarea.input { resize: vertical; }
.input.code { text-transform: uppercase; letter-spacing: .15em; font-weight: 600; }
label { display: block; font-weight: 500; margin: .7em 0 .25em; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.btn {
  border: 0; border-radius: 10px; padding: .6em 1.1em; font-weight: 600; cursor: pointer; background: #fff;
  box-shadow: inset 0 0 0 2px var(--line); white-space: nowrap;
}
.btn:hover { box-shadow: inset 0 0 0 2px var(--croc); }
.btn.primary { background: var(--croc); color: #fff; box-shadow: 0 3px 0 var(--croc-d); }
.btn.sun { background: var(--sun); box-shadow: 0 3px 0 var(--sun-d); }
.btn.danger { color: var(--coral); }
.btn.primary:active, .btn.sun:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.btn.on { background: var(--sun); box-shadow: 0 3px 0 var(--sun-d); }
.btn.wide { width: 100%; margin-top: .6em; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

.toast {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .7em 1.2em; border-radius: 999px; z-index: 50; max-width: 92vw; text-align: center;
}

/* ---------- вход ---------- */
.welcome { max-width: 480px; margin: 4vh auto 0; }
.tabs-row { display: flex; gap: 4px; margin: 1em 0 .5em; border-bottom: 2px solid var(--line); }
.tabs-row button {
  flex: 1; background: none; border: 0; padding: .6em .3em; cursor: pointer; font-weight: 500; color: var(--muted);
  border-bottom: 4px solid transparent; margin-bottom: -2px;
}
.tabs-row button.on { color: var(--ink); border-bottom-color: var(--sun); font-weight: 600; }

/* ---------- главная ---------- */
.home { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.span-all { grid-column: 1 / -1; }
.resume { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; background: #FFF6DA; border-color: var(--sun); }
.seg { display: grid; gap: 6px; margin-bottom: .6em; }
.seg label { margin: 0; font-weight: 400; display: flex; gap: 8px; align-items: center; }
.roomlist, .decklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.roomlist li, .decklist li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--mist); border-radius: 10px;
}
.page { display: grid; gap: 16px; max-width: 820px; margin: 0 auto; }

/* ---------- комната ---------- */
.game {
  display: grid; gap: 14px; align-items: start;
  grid-template-columns: 220px minmax(0, 1fr) 300px;
  grid-template-areas: "players stage chat";
}
.players { grid-area: players; }
.stage { grid-area: stage; min-width: 0; }
.chat { grid-area: chat; }
.tabs { display: none; }

.plist { list-style: none; margin: 0 0 .8em; padding: 0; display: grid; gap: 6px; }
.plist li { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px; background: var(--mist); position: relative; }
.plist li.me { box-shadow: inset 0 0 0 2px var(--croc); }
.plist li.off { opacity: .5; }
.pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.gain { color: var(--croc); font-weight: 600; font-size: .9rem; }
.kick summary { cursor: pointer; list-style: none; padding: 0 6px; border-radius: 6px; color: var(--muted); }
.kick summary::-webkit-details-marker { display: none; }
.kick[open] .menu { position: absolute; right: 6px; top: calc(100% - 4px); z-index: 5; background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 6px; display: grid; gap: 4px; }

.status { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 12px; align-items: center; margin-bottom: 6px; }
.round { font-weight: 500; color: var(--muted); }
.clock { font-weight: 700; font-variant-numeric: tabular-nums; background: var(--bayou); color: var(--sun); border-radius: 999px; padding: .15em .8em; }
.tiles { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; min-height: 34px; }
.tile {
  min-width: clamp(20px, 3vw, 34px); height: clamp(28px, 4vw, 42px); display: grid; place-items: center;
  font-weight: 700; font-size: clamp(1rem, 2.4vw, 1.6rem); text-transform: uppercase; background: #fff; border-radius: 6px;
  border-bottom: 4px solid var(--sun); box-shadow: inset 0 0 0 1.5px var(--line);
}
.tile.gap { background: none; border-bottom-color: transparent; box-shadow: none; min-width: 12px; }
.timebar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-bottom: 8px; }
.timebar i { display: block; height: 100%; background: var(--croc); transition: width 1s linear; }

.canvaswrap { position: relative; aspect-ratio: 4 / 3; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; background: #fff; }
.canvaswrap canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.canvaswrap.mine canvas { cursor: crosshair; }
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(14, 59, 53, .88); color: #fff; text-align: center; padding: 16px;
}
.overlay .big { font-size: clamp(1.1rem, 3vw, 1.7rem); font-weight: 600; margin: 0; }
.overlay .big b { color: var(--sun); text-transform: uppercase; }
.gains { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.gains b { color: var(--sun); }

.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; padding: 0; }
.sw.on { box-shadow: 0 0 0 3px var(--ink); }
.sz { width: 36px; height: 36px; border-radius: 10px; border: 0; background: var(--mist); display: grid; place-items: center; cursor: pointer; }
.sz i { display: block; border-radius: 50%; background: var(--ink); }
.sz.on { box-shadow: inset 0 0 0 2px var(--ink); }
.sep { width: 1px; height: 26px; background: var(--line); }

.log {
  list-style: none; margin: 0 0 10px; padding: 8px; height: min(56vh, 460px); overflow-y: auto; background: var(--mist);
  border-radius: 10px; display: flex; flex-direction: column; gap: 4px; word-break: break-word;
}
.log .sys { color: var(--muted); font-style: italic; }
.log .good { color: var(--croc); font-weight: 600; }
.log .private { color: var(--sky); }

.lobbybox { display: grid; gap: 14px; }
.invite .bigcode { font-size: 1.3rem; letter-spacing: .18em; background: var(--sun); padding: 0 .4em; border-radius: 6px; }
.settings { border: 1.5px solid var(--line); border-radius: 10px; padding: 4px 14px 12px; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.settings legend { padding: 0 6px; font-weight: 600; }
.settings label.check { grid-column: 1 / -1; margin-top: 12px; }
.podium { list-style: none; padding: 0; margin: 0 0 .5em; display: grid; gap: 6px; }
.podium li { display: flex; justify-content: space-between; padding: 10px 14px; background: var(--mist); border-radius: 10px; }
.podium li.win { background: var(--sun); font-weight: 600; }

/* ---------- профиль, таблицы ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stats div { background: var(--mist); border-radius: 10px; padding: 12px; display: grid; }
.stats b { font-size: 1.8rem; line-height: 1.1; }
.stats span { color: var(--muted); font-size: .9rem; }
.scroll-x { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; }

/* ---------- планшет: сетка из двух колонок ---------- */
@media (max-width: 1000px) {
  .home { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game { grid-template-columns: minmax(0, 1fr) 260px; grid-template-areas: "stage chat" "players chat"; }
  .chat { align-self: stretch; }
  .log { height: min(60vh, 520px); }
}

/* ---------- телефон: flexbox, панели переключаются вкладками ---------- */
@media (max-width: 640px) {
  .home { display: flex; flex-direction: column; }
  .game { display: flex; flex-direction: column; gap: 10px; }
  .stage { order: 1; }
  .tabs { order: 2; display: flex; gap: 6px; }
  .tabs button { flex: 1; padding: .6em; border: 0; border-radius: 10px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line); font-weight: 500; }
  .tabs button.on { background: var(--bayou); color: #fff; }
  .side { order: 3; }
  .side.off { display: none; }
  .log { height: 34vh; }
  .status { grid-template-columns: 1fr auto; }
  .status .tiles { grid-column: 1 / -1; order: 3; }
  .settings { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .top { justify-content: center; }
  .roomlist li { flex-direction: column; align-items: stretch; }
  .btn { padding: .7em 1em; }
}

@media (prefers-reduced-motion: reduce) { .timebar i { transition: none; } }
