/* www/style.css */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: system-ui, sans-serif;
  background: #1a1a2e;
  color: #eee;
  overflow: hidden; /* no scroll — everything fits in viewport */
}

/* ── Screen management ───────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; align-items: center;
                 justify-content: center; height: 100dvh; }

/* ── Color selection screen ──────────────────────────────────── */
h1 { font-size: clamp(2rem, 8vw, 4rem); margin-bottom: 1rem; }
.prompt { font-size: clamp(1rem, 4vw, 1.5rem); margin-bottom: 1.5rem; }
.note   { font-size: clamp(0.8rem, 3vw, 1rem); margin-top: 1rem; opacity: 0.7; }

.color-buttons { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }

.color-btn {
  min-width: 48px; min-height: 48px;
  padding: 0.75rem 2rem;
  font-size: clamp(1rem, 4vw, 1.25rem);
  border: none; border-radius: 8px; cursor: pointer;
  background: #4a90d9; color: #fff; font-weight: bold;
  transition: background 0.15s;
}
.color-btn:hover { background: #357abd; }

.difficulty-row {
  display: flex; align-items: center; gap: 0.75rem;
  margin-top: 1.5rem;
  font-size: clamp(1rem, 4vw, 1.25rem);
}
.difficulty-row select {
  font-size: inherit;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: none;
  background: #2a2a4a;
  color: #eee;
  cursor: pointer;
}

/* ── Game layout — portrait (default) ───────────────────────── */
.game-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  align-items: center;
}

.score-bar, .status-bar {
  width: 100%;
  padding: 0.5rem 1rem;
  font-size: clamp(1rem, 3vw, 1.25rem);
  text-align: center;
  flex-shrink: 0;
}
.score-bar { display: flex; justify-content: space-around; gap: 1rem; align-items: center; }
#ai-emoji { font-size: clamp(1.5rem, 5vw, 2.5rem); line-height: 1; }

.board-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
}

#board-canvas {
  /* Square: limited by available width OR available height, whichever is smaller */
  width:  min(100%, 100cqh);
  height: min(100%, 100cqw);
  aspect-ratio: 1;
  touch-action: none; /* prevent scroll-on-drag on mobile */
}

/* ── Game layout — landscape ─────────────────────────────────── */
@media (orientation: landscape) {
  .game-layout {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: 1fr 1fr;
  }

  /* Board spans both rows on the left */
  .board-area {
    grid-column: 1;
    grid-row: 1 / 3;
    height: 100dvh;
    width: auto;
  }
  #board-canvas {
    width: auto;
    height: 100dvh;
    aspect-ratio: 1;
  }

  /* Score and status stack in the right column */
  .score-bar {
    grid-column: 2;
    grid-row: 1;
    width: auto;
    padding: 1rem;
    align-self: end;
  }
  .status-bar {
    grid-column: 2;
    grid-row: 2;
    width: auto;
    padding: 1rem;
    align-self: start;
  }
}

/* ── Game over screen ────────────────────────────────────────── */
#screen-over h2   { font-size: clamp(1.5rem, 6vw, 3rem); margin-bottom: 1rem; }
#screen-over p    { font-size: clamp(1rem, 4vw, 1.5rem); margin-bottom: 2rem; }
#btn-play-again   { width: min(80vw, 300px); }
