:root {
  --bg: #8ec5e8;
  --board: rgba(109, 127, 151, 0.72);
  --text: #4a5568;
  --btn: #ff6b9d;
  --btn-hover: #ff85ad;
  --btn-secondary: #6d7f97;
  --cell-size: min(11vw, 70px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg) url("./assets/bg.png") center / cover no-repeat fixed;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.brand-mark {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.mode-screen {
  width: min(100%, 420px);
  padding: 32px 24px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}

.mode-screen h1 {
  margin: 8px 0;
  font-size: clamp(32px, 8vw, 44px);
  color: #ff6b9d;
}

.mode-desc {
  margin: 0 0 24px;
  line-height: 1.5;
}

.mode-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-screen {
  width: min(100%, 640px);
}

.game-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.title-block h2 {
  margin: 4px 0 0;
  font-size: clamp(24px, 6vw, 32px);
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.hud {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-box {
  min-width: 72px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.hud-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.75;
}

.hud-value {
  display: block;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}

.board-wrap {
  display: flex;
  justify-content: center;
}

.grid {
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  grid-template-rows: repeat(8, var(--cell-size));
  gap: 4px;
  padding: 8px;
  border-radius: 12px;
  background: var(--board);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25), 0 4px 16px rgba(0, 0, 0, 0.15);
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.cell:hover {
  transform: scale(1.04);
}

.cell.selected {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px #ff6b9d;
  transform: scale(1.06);
}

.cell.empty {
  opacity: 0.35;
}

.toolbar {
  margin-top: 16px;
  text-align: center;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 12px 20px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary {
  background: var(--btn);
  color: #fff;
}

.btn-primary:hover {
  background: var(--btn-hover);
}

.btn-secondary {
  background: var(--btn-secondary);
  color: #fff;
}

.hint {
  margin: 12px 0 0;
  text-align: center;
  font-size: 13px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.mobile-hint {
  display: none;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  z-index: 20;
}

.overlay-card {
  width: min(90%, 360px);
  padding: 24px;
  border-radius: 14px;
  background: #fff;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.overlay-card h2 {
  margin: 0 0 8px;
  font-size: 28px;
  color: #ff6b9d;
}

.overlay-card p {
  margin: 0 0 16px;
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 640px), (hover: none) and (pointer: coarse) {
  :root {
    --cell-size: min(11vw, 44px);
  }

  .desktop-hint {
    display: none;
  }

  .mobile-hint {
    display: block;
  }
}

@media (min-width: 641px) {
  :root {
    --cell-size: 70px;
  }
}
