/* =========================================================
   Threat Sweeper — game-specific styles
   ========================================================= */

.game-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1.5rem 0; flex-wrap: wrap;
}
.back { color: var(--muted); text-decoration: none; font-size: .9rem; }
.back:hover { color: var(--accent); }

/* ---------------- start ---------------- */

.start-inner { padding: clamp(1.5rem, 6vw, 4rem) 0 2rem; max-width: 62ch; }

.rules { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.75rem; }
.rule { color: var(--muted); font-size: .96rem; display: flex; gap: .7rem; align-items: baseline; }
.rule-n {
  flex: none;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-hi); border: 1px solid var(--line-hi);
  color: var(--accent); font-size: .75rem; font-weight: 800;
}

/* ---------------- HUD ---------------- */

.hud { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-bottom: .6rem; }
.hud-cell {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: .55rem .8rem;
  display: flex; flex-direction: column; gap: .1rem;
}
.hud-label { font-size: .62rem; text-transform: uppercase; letter-spacing: .16em; color: var(--dim); font-weight: 700; }
.hud-val   { font-size: clamp(1.1rem, 3vw, 1.5rem); font-weight: 800; font-variant-numeric: tabular-nums; }
.hud-cell.is-low .hud-val { color: var(--danger); }

.timebar { height: 5px; background: var(--panel); border-radius: 99px; overflow: hidden; margin-bottom: 1.25rem; }
.timebar-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.timebar-fill.is-low { background: var(--danger); }

/* ---------------- board ---------------- */

.board-wrap { display: flex; justify-content: center; }

.board {
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 900px;        /* wide logos need the extra tile width to stay legible */
  user-select: none;
  touch-action: manipulation;
}

.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line-hi);
  border-radius: 9px;
  background: linear-gradient(160deg, var(--panel-hi), var(--panel));
  cursor: pointer;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s ease, border-color .15s ease, background .15s ease;
  padding: 0;
  font: inherit;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.tile:hover:not(.is-open) { border-color: var(--accent); transform: translateY(-2px); }
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* subtle idle sheen so a closed board doesn't look dead */
.tile:not(.is-open)::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(140deg, rgba(255,255,255,.05), transparent 55%);
  pointer-events: none;
}

/* ---- opened ---- */

.tile.is-open {
  cursor: default;
  border-color: var(--line);
  background: var(--bg-2);
  animation: tile-open .22s ease both;
}
.tile.is-open:hover { transform: none; }

@keyframes tile-open {
  from { transform: scale(.86); opacity: .35; }
  to   { transform: none; opacity: 1; }
}

/* The artwork is wide product logos with dark wordmarks, so tiles
   fit them whole rather than cropping, on a light plaque that keeps
   the lettering readable. */
.tile img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;      /* fit whole — never crop, never squash */
  padding: 8%;
  display: block;
  z-index: 2;
}

.tile.has-art.is-open,
.tile.is-mine.is-open {
  background: #f2f6fb;
  border-color: #cbd7e6;
}
.tile.has-art .tile-face { display: none; }

/* the threat tile keeps the same light plaque but reads as danger */
.tile.is-mine.is-open {
  border-color: var(--danger);
  box-shadow: inset 0 0 0 2px rgba(244,63,94,.55);
}
.tile.is-mine .tile-face { display: none; }
.tile.is-mine img { padding: 14%; }

/* Themed face used until artwork is supplied, and as the
   fallback when an image path is wrong. */
.tile-face {
  position: absolute; inset: 0;
  background:
    radial-gradient(70% 70% at 30% 25%, rgba(34,211,238,.16), transparent 70%),
    linear-gradient(160deg, #16203a, #0d1424);
}

/* adjacency count */
.tile-n {
  position: relative;
  z-index: 2;
  font-weight: 900;
  font-size: clamp(.95rem, 2.6vw, 1.35rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
/* when art is present the number sits in a corner chip so it
   stays readable over any image */
.tile.has-art .tile-n {
  position: absolute; right: 3px; bottom: 2px;
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(4,8,16,.82);
  font-size: clamp(.7rem, 2vw, .95rem);
}

.n1 { color: #38bdf8; }
.n2 { color: #34d399; }
.n3 { color: #fbbf24; }
.n4 { color: #a78bfa; }
.n5 { color: #fb7185; }
.n6 { color: #22d3ee; }
.n7 { color: #f472b6; }
.n8 { color: #f43f5e; }

/* ---- flagged ---- */

.tile.is-flag {
  border-color: var(--warn);
  background: rgba(245,158,11,.14);
}
.tile-flag { position: relative; z-index: 2; font-size: clamp(1rem, 3vw, 1.4rem); }

/* ---- mine ---- */

.tile.is-mine {
  border-color: var(--danger);
  background: rgba(244,63,94,.18);
}
.tile.is-boom {
  animation: boom .45s ease both;
  border-color: var(--danger);
  background: rgba(244,63,94,.4);
}
.tile-bomb { position: relative; z-index: 2; font-size: clamp(1.1rem, 3.2vw, 1.6rem); }

@keyframes boom {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.28); }
  100% { transform: scale(1); }
}

.board.is-shake { animation: shake .35s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

.board-hint { margin-top: 1rem; text-align: center; }

/* final board on the end screen — read-only and smaller */
.board.is-final { max-width: 540px; gap: 4px; }
.board.is-final .tile { cursor: default; border-radius: 6px; }
.board.is-final .tile:hover { transform: none; border-color: var(--line-hi); }

/* ---------------- end screen ---------------- */

.result-head { text-align: center; padding: 2rem 0 2.25rem; }
.result-head .title { font-size: clamp(3rem, 11vw, 5.5rem); font-variant-numeric: tabular-nums; }

.result-grid {
  display: grid; gap: 1.25rem;
  grid-template-columns: 1.1fr 1fr;
  align-items: start; margin-bottom: 1.5rem;
}
@media (max-width: 820px) { .result-grid { grid-template-columns: 1fr; } }

/* ---------------- responsive ---------------- */

@media (max-width: 560px) {
  .hud { grid-template-columns: repeat(2, 1fr); }
  .board { gap: 4px; }
  .tile { border-radius: 7px; }
}
