:root {
  --bg: #07111d;
  --bg-deep: #030912;
  --panel: rgba(10, 24, 39, .94);
  --panel-soft: rgba(15, 35, 55, .92);
  --line: rgba(109, 191, 255, .23);
  --line-strong: rgba(90, 201, 255, .52);
  --ink: #e9f4ff;
  --muted: #8fa9be;
  --blue: #36b7ff;
  --cyan: #46e6ff;
  --green: #22d887;
  --amber: #f0b743;
  --red: #ff5364;
  --shadow: 0 16px 44px rgba(0,0,0,.30);
  --gap: clamp(3px, .62vw, 6px);
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 50% -10%, rgba(41,145,219,.16), transparent 38%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  padding:
    max(14px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

button { font: inherit; }

.app-shell {
  width: min(96vw, 760px);
  margin: 0 auto;
}

.brandbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin: 1px auto 13px;
  color: var(--ink);
}

.brand-logo {
  width: clamp(92px, 18vw, 138px);
  height: auto;
  max-height: 76px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 0 10px rgba(18,185,255,.22));
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.02;
  letter-spacing: .12em;
}

.brand-name {
  font-size: 13px;
  font-weight: 800;
  color: #dff4ff;
}

.brand-subtitle {
  margin-top: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .21em;
  color: var(--blue);
}

.topbar {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.stat { text-align: center; color: var(--muted); }

.stat .label {
  display: block;
  font-size: clamp(14px, 3vw, 20px);
  line-height: 1;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  color: var(--ink);
  font-size: clamp(28px, 6vw, 42px);
  line-height: 1.05;
  text-shadow: 0 0 18px rgba(54,183,255,.15);
}

.icon-btn {
  width: 52px;
  height: 52px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-soft);
  color: var(--cyan);
  box-shadow: var(--shadow);
  font-size: 30px;
}

.status-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.pill {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 18px;
  box-shadow: var(--shadow);
  font-size: clamp(17px, 3vw, 21px);
  color: var(--ink);
}

.mistakes { min-width: 170px; text-align: center; color: #ff8390; }

.rules {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 8px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.rules div {
  background: rgba(22, 51, 78, .72);
  border: 1px solid rgba(88, 179, 235, .15);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: clamp(12px, 2.4vw, 16px);
  font-weight: 650;
  color: #cce9fb;
}

.board-wrap {
  background: rgba(7,18,30,.88);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 9px;
  box-shadow: 0 0 0 1px rgba(70,230,255,.05), var(--shadow);
}

.board {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  grid-template-rows: repeat(10, minmax(0, 1fr));
  gap: var(--gap);
  width: 100%;
  aspect-ratio: 1 / 1;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

.cell {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: clamp(4px, .9vw, 8px);
  display: grid;
  place-items: center;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  transform: none !important;
  transition: filter .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.cell:active {
  transform: none !important;
  filter: brightness(1.10);
}

.cell.revealed {
  box-shadow:
    inset 0 0 0 2px rgba(255,255,255,.72),
    0 0 12px rgba(70,230,255,.18);
  border-color: rgba(255,255,255,.55);
}

.mark-x,
.mark-cat,
.wrong {
  display: block;
  width: 100%;
  line-height: 1;
  text-align: center;
  pointer-events: none;
}

.mark-x {
  font-size: clamp(22px, 6.4vw, 48px);
  color: rgba(242,249,255,.90);
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
}

.mark-cat {
  font-size: clamp(22px, 6.4vw, 48px);
  filter: drop-shadow(0 2px 1px rgba(0,0,0,.28));
}

.wrong {
  font-size: clamp(24px, 6.7vw, 50px);
  color: var(--red);
  background: rgba(255,255,255,.28);
  text-shadow: 0 0 5px rgba(0,0,0,.8);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px auto 10px;
  width: min(440px, 92%);
}

.control-btn {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(18,44,68,.96), rgba(9,27,44,.96));
  color: var(--ink);
  padding: 11px 14px;
  box-shadow: var(--shadow);
  font-weight: 750;
}

.control-btn .big {
  display: block;
  font-size: 29px;
  line-height: 1.1;
}

.control-btn:disabled {
  opacity: .38;
  filter: grayscale(1);
}

.help {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 8px 18px;
}

.help strong { color: #cdeaff; }

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: rgba(4,15,25,.96);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 16px;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  max-width: min(90vw, 560px);
  text-align: center;
  box-shadow: var(--shadow);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,.62);
  padding: 20px;
}

.hidden { display: none; }

.modal-card {
  width: min(92vw, 400px);
  background: linear-gradient(180deg, #10273d, #081827);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0,0,0,.50);
}

.modal-card h2 { margin-top: 0; color: var(--ink); }
.modal-card p { color: #b9cfdf; line-height: 1.5; }

.modal-card button {
  border: 1px solid rgba(70,230,255,.40);
  border-radius: 999px;
  padding: 12px 20px;
  background: linear-gradient(180deg, #16b9d7, #118bb0);
  color: white;
  font-weight: 800;
  min-width: 150px;
  box-shadow: 0 0 20px rgba(70,230,255,.14);
}

@media (max-width: 540px) {
  .app-shell { width: 100%; }
  .board-wrap { padding: 7px; border-radius: 15px; }
  .brandbar { margin-bottom: 10px; }
}

@media (orientation: landscape) and (max-height: 620px) {
  body { padding-top: 8px; }
  .app-shell { width: min(92vw, 560px); }
  .brandbar, .rules, .help { display: none; }
  .controls { margin-top: 8px; }
}

.x-hint-icon {
  color: #f3fbff;
  text-shadow: 0 0 12px rgba(70,230,255,.25);
}
