/* Крокомания — гибрид: тёмная база + чистая сетка + маскот.
 * Дисциплина: одна сетка, один акцент (зелёный), много воздуха. */

:root {
  --bg:      #0d1413;
  --bg-2:    #101c18;
  --card:    #16231f;
  --card-2:  #1d3029;
  --line:    #21352e;
  --text:    #eaf5ef;
  --hint:    #7e9a8d;
  --accent:  #35d27b;
  --accent-2:#29b869;
  --lime:    #b6ff5c;
  --danger:  #ff5c5c;
  --ink:     #062013;
  --radius:  20px;
  --gap:     14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(130% 70% at 50% -10%, #14322a 0%, rgba(20,50,42,0) 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 480px; margin: 0 auto; padding: 28px 20px 48px; }

.screen { display: none; animation: fade .28s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- ГЛАВНАЯ ---------- */
.hero { text-align: center; margin: 18px 0 30px; }
.mascot {
  width: 150px; height: auto; display: block; margin: 0 auto;
  filter: drop-shadow(0 12px 26px rgba(53,210,123,.4));
  animation: bob 3.2s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-10px) rotate(2deg); } }

.brand { font-size: 38px; font-weight: 900; letter-spacing: -.5px; margin: 14px 0 4px; }
.brand span { color: var(--accent); }
.subtitle { color: var(--hint); margin: 0; font-size: 15px; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--hint); font-size: 13px; margin: 22px 2px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- КНОПКИ ---------- */
.btn {
  width: 100%; border: 0; border-radius: var(--radius);
  padding: 17px; font-size: 17px; font-weight: 800;
  cursor: pointer; transition: transform .12s ease, filter .12s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--ink); box-shadow: 0 8px 22px rgba(53,210,123,.28);
}
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }

.join-row { display: flex; gap: 10px; }
.join-row input {
  flex: 1; text-align: center; text-transform: uppercase; letter-spacing: 8px;
  font-size: 22px; font-weight: 800; border: 1px solid var(--line);
  background: var(--card); color: var(--text); border-radius: var(--radius); padding: 15px;
}
.join-row input:focus { outline: none; border-color: var(--accent); }
.join-row .btn { width: auto; padding: 15px 24px; }

.error { color: var(--danger); text-align: center; min-height: 20px; margin-top: 14px; font-size: 14px; }
.hint { color: var(--hint); font-size: 13px; text-align: center; margin-top: 12px; }
.muted { opacity: .8; }

/* ---------- ЛОББИ ---------- */
.lobby-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 8px; }
.mascot-sm { width: 52px; height: auto; filter: drop-shadow(0 6px 14px rgba(53,210,123,.35)); }
.room-code { color: var(--hint); font-size: 13px; line-height: 1.5; }
.room-code b { display: block; color: var(--accent); letter-spacing: 6px; font-size: 30px; font-weight: 900; }

h2 { font-size: 18px; margin: 22px 0 12px; }

.players { list-style: none; padding: 0; margin: 0 0 8px; }
.players li {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px; margin-bottom: 10px;
  display: flex; justify-content: space-between; align-items: center;
}
.players .name { font-weight: 600; }
.players .score { background: var(--accent); color: var(--ink); border-radius: 999px; padding: 3px 12px; font-weight: 800; font-size: 13px; }
.players .crown { margin-left: 6px; }

button#btn-invite { margin-bottom: 10px; }
button#btn-startgame { margin-top: 4px; }

/* ---------- ИГРА ---------- */
.game-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.round-pill { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 16px; font-weight: 700; font-size: 14px; }
.timer { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 18px; font-weight: 900; font-size: 18px; min-width: 56px; text-align: center; }
.timer.low { background: var(--danger); border-color: var(--danger); color: #fff; animation: pulse .6s infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }

.word-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; text-align: center; margin-bottom: 16px; }
.word-box .label { color: var(--hint); margin: 0 0 6px; font-size: 14px; }
.the-word { font-size: 38px; font-weight: 900; color: var(--accent); margin: 10px 0; letter-spacing: .5px; text-shadow: 0 4px 20px rgba(53,210,123,.35); }
.hint-big { font-size: 22px; font-weight: 800; margin-top: 8px; color: var(--text); }

.feed { list-style: none; padding: 0; margin: 0 0 14px; max-height: 38vh; overflow-y: auto; }
.feed li { padding: 10px 14px; border-radius: 13px; margin-bottom: 7px; background: var(--card); border: 1px solid var(--line); font-size: 15px; }
.feed li.correct { background: linear-gradient(135deg, var(--accent), var(--lime)); border-color: transparent; color: var(--ink); font-weight: 800; }
.feed li.system { background: transparent; border: 0; color: var(--hint); text-align: center; font-size: 13px; }
.feed li .who { color: var(--hint); margin-right: 6px; }

.guess-row { display: flex; gap: 10px; }
.guess-row input {
  flex: 1; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: var(--radius); padding: 15px 16px; font-size: 16px;
}
.guess-row input:focus { outline: none; border-color: var(--accent); }
.guess-row .btn { width: 56px; padding: 0; font-size: 22px; }

/* ---------- РЕЖИМ СОЗДАНИЯ ---------- */
.mode-toggle { display: flex; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 5px; margin-bottom: 14px; }
.mode-btn { flex: 1; border: 0; background: transparent; color: var(--hint); font-weight: 700; font-size: 15px; padding: 12px; border-radius: 14px; cursor: pointer; transition: all .15s ease; }
.mode-btn.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--ink); }

.mode-badge { text-align: center; color: var(--hint); font-size: 13px; margin: 0 0 4px; }

/* ---------- ДОСКА РИСОВАНИЯ ---------- */
.board-wrap { margin-bottom: 14px; }
#board { width: 100%; aspect-ratio: 10 / 7; background: #ffffff; border-radius: var(--radius); border: 1px solid var(--line); touch-action: none; display: block; box-shadow: 0 8px 22px rgba(0,0,0,.25); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; padding: 0; transition: transform .12s ease; }
.swatch.active { border-color: var(--text); transform: scale(1.15); }
.tool { background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 8px 13px; font-size: 16px; cursor: pointer; }
.tool.active { background: var(--accent); border-color: var(--accent); color: var(--ink); }

.hidden { display: none !important; }

/* --- уведомления (фолбэк, если Telegram не поддерживает showAlert) --- */
.toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%) translateY(20px);
  background:var(--card,#16231f);color:var(--text,#eaf5ef);border:1px solid var(--line,#21352e);
  border-radius:14px;padding:12px 18px;font-size:14px;max-width:80%;text-align:center;
  z-index:9999;opacity:0;pointer-events:none;transition:opacity .2s,transform .2s;
  box-shadow:0 10px 30px rgba(0,0,0,.45)}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}

/* --- счётчик игроков в лобби --- */
.count{display:inline-block;min-width:22px;padding:0 8px;margin-left:6px;
  font-size:14px;line-height:22px;text-align:center;border-radius:999px;
  background:var(--line,#21352e);color:var(--lime,#b6ff5c);vertical-align:middle}
.now-draw{margin-left:6px}

/* --- поле ника --- */
.nick-row { margin-bottom: 14px; }
.nick-row input {
  width: 100%; box-sizing: border-box; text-align: center;
  font-size: 17px; font-weight: 700; border: 1px solid var(--line);
  background: var(--card); color: var(--text); border-radius: var(--radius); padding: 14px;
}
.nick-row input:focus { outline: none; border-color: var(--accent); }
.nick-row input::placeholder { color: var(--hint); font-weight: 600; }


/* ============ ДОПОЛНЕНИЯ ============ */

/* зелёное выделение (вместо синего) */
::selection { background: var(--accent); color: var(--ink); }
::-moz-selection { background: var(--accent); color: var(--ink); }
input::selection, textarea::selection { background: var(--accent); color: var(--ink); }

/* фикс «не влезает» на главной */
.join-row { width: 100%; }
.join-row input { letter-spacing: 6px; min-width: 0; padding: 15px 12px; }
.join-row .btn { white-space: nowrap; padding: 15px 18px; flex: none; }

/* опасная кнопка-призрак (Выйти) */
.btn-danger-ghost {
  background: transparent; color: var(--danger);
  border: 1px solid rgba(255,92,92,.4); margin-top: 12px;
}
.btn-danger-ghost:active { transform: scale(.97); }

/* игровые кнопки внизу */
.game-actions { display: flex; gap: 10px; margin-top: 16px; }
.game-actions .btn { margin-top: 0; }

/* список игроков: правая группа + кнопка кика */
.players .pl-right { display: flex; align-items: center; gap: 8px; }
.kick-btn {
  background: transparent; border: 1px solid var(--line); color: var(--danger);
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  font-size: 13px; line-height: 1; flex: none; padding: 0;
}
.kick-btn:active { transform: scale(.9); }

/* реплики ведущего */
.feed li.hint-msg { background: var(--card-2); border-color: var(--accent); }

/* баннер «угадал!» */
.round-banner {
  position: fixed; left: 50%; top: 18px;
  transform: translateX(-50%) translateY(-20px);
  background: linear-gradient(135deg, var(--accent), var(--lime));
  color: var(--ink); font-weight: 800; padding: 12px 22px; border-radius: 16px;
  z-index: 9998; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.round-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* расширенная рисовалка */
.tools { flex-direction: column; align-items: stretch; gap: 10px; }
.palette { display: flex; flex-wrap: wrap; gap: 8px; }
.sizes { display: flex; gap: 8px; align-items: center; }
.size-btn {
  width: 44px; height: 36px; display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
.size-btn.active { border-color: var(--accent); background: var(--card-2); }
.size-btn .dot { display: block; border-radius: 50%; background: var(--text); }
.dot.s1 { width: 5px; height: 5px; }
.dot.s2 { width: 10px; height: 10px; }
.dot.s3 { width: 16px; height: 16px; }
.dot.s4 { width: 22px; height: 22px; }
.tool-actions { display: flex; gap: 8px; }
.tool-actions .tool { flex: 1; }
