:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #16213e;
  --accent: #e94560;
  --accent2: #0f3460;
  --text: #eee;
  --text-dim: #888;
  --tile-radius: 12px;
  --gap: 4px;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
  max-width: 100%;
}

/* Header */
h1 {
  font-size: 2rem;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--accent), #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

/* Controls */
.controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.controls button,
.controls select {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
}

.controls button:hover {
  background: var(--accent);
  transform: translateY(-1px);
}

.controls select {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23eee' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.controls select:focus {
  border: 1px solid var(--accent);
}

/* Stats */
.stats {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  font-size: 1rem;
}

.stats span { color: var(--text-dim); }
.stats strong { color: var(--text); }

/* Board */
.board-container {
  position: relative;
  max-width: 100%;
}

.board {
  display: grid;
  gap: var(--gap);
  padding: var(--gap);
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
              inset 0 1px 0 rgba(255, 255, 255, 0.05);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  max-width: 100%;
}

/* Tiles */
.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--tile-radius);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  background: linear-gradient(145deg, var(--surface2), #1a1a3e);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.tile:not(.empty):hover {
  transform: scale(1.04);
  box-shadow: 0 4px 16px rgba(233, 69, 96, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.tile:not(.empty):active {
  transform: scale(0.97);
}

.tile.empty {
  background: transparent;
  box-shadow: none;
  cursor: default;
}

.tile.correct {
  background: linear-gradient(145deg, #1a3a2e, #16213e);
  box-shadow: 0 2px 8px rgba(0, 255, 100, 0.15),
              inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Win Overlay */
.win-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 100;
  animation: fadeIn 0.3s;
}

.win-overlay.show { display: flex; }

.win-overlay h2 {
  font-size: 3rem;
  margin-bottom: 8px;
  animation: bounceIn 0.5s;
}

.win-overlay p {
  color: var(--text-dim);
  margin-bottom: 20px;
  font-size: 1.1rem;
}

.win-overlay button {
  padding: 12px 32px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s;
}

.win-overlay button:hover {
  transform: scale(1.05);
}

/* Confetti */
.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  z-index: 101;
  animation: confettiFall 3s ease-out forwards;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Responsive */
@media (max-width: 480px) {
  h1 { font-size: 1.5rem; }
  .stats { gap: 16px; font-size: 0.9rem; }
}

/* Bitesize Arcade premium skin */
:root {
  --bg: #08131d;
  --surface: rgba(13, 26, 38, 0.92);
  --surface2: rgba(255, 246, 220, 0.08);
  --accent: #ffb84d;
  --accent2: #38d8ff;
  --text: #fff4df;
  --text-dim: rgba(255, 244, 223, 0.68);
  --tile-radius: 10px;
  --gap: 6px;
}

body {
  background:
    radial-gradient(circle at 16% 14%, rgba(56, 216, 255, 0.18), transparent 32%),
    radial-gradient(circle at 84% 12%, rgba(255, 184, 77, 0.15), transparent 30%),
    linear-gradient(180deg, #08131d 0%, #101927 56%, #160f1b 100%);
  justify-content: flex-start;
  min-height: 100svh;
  padding: clamp(20px, 4vw, 34px);
  overflow-x: hidden;
}

h1 {
  margin-top: 0;
  color: var(--text);
  background: none;
  -webkit-text-fill-color: currentColor;
  font-size: clamp(2rem, 6vw, 3.5rem);
  line-height: 0.96;
  text-shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
}

.subtitle {
  color: var(--text-dim);
  margin-bottom: 18px;
}

.controls,
.stats,
.board-container {
  width: min(620px, 100%);
  max-width: 100%;
}

.controls button,
.controls select {
  border: 1px solid rgba(255, 246, 220, 0.14);
  border-radius: 999px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 246, 220, 0.12), rgba(255, 246, 220, 0.05)),
    rgba(8, 19, 29, 0.76);
  box-shadow: inset 0 1px 0 rgba(255, 246, 220, 0.08);
}

.controls button:hover {
  color: #1a1008;
  background: linear-gradient(180deg, #ffd36d, #ff934d);
  box-shadow: 0 12px 24px rgba(255, 147, 77, 0.24);
}

.stats {
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
}

.stats div {
  min-width: 0;
  flex: 1 1 0;
  border: 1px solid rgba(56, 216, 255, 0.16);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: center;
  background: rgba(255, 246, 220, 0.07);
}

.stats span {
  display: block;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stats strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 1.2rem;
}

.board-container {
  display: grid;
  place-items: center;
  border: 1px solid rgba(56, 216, 255, 0.2);
  border-radius: 18px;
  padding: clamp(10px, 2vw, 16px);
  background:
    linear-gradient(180deg, rgba(255, 246, 220, 0.1), rgba(255, 246, 220, 0.04)),
    rgba(7, 16, 25, 0.72);
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 246, 220, 0.08);
  overflow: hidden;
}

.board {
  background: rgba(5, 12, 19, 0.86);
  box-shadow:
    0 18px 45px rgba(0, 0, 0, 0.36),
    inset 0 1px 0 rgba(255, 246, 220, 0.08);
}

.tile {
  color: #fff6df;
  background:
    linear-gradient(145deg, rgba(56, 216, 255, 0.34), rgba(255, 184, 77, 0.2)),
    rgba(255, 246, 220, 0.1);
  border: 1px solid rgba(255, 246, 220, 0.12);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 246, 220, 0.12);
}

.tile.correct {
  color: #0b151d;
  background: linear-gradient(145deg, #82f6bd, #37d8ff);
}

.win-overlay {
  background: rgba(5, 12, 19, 0.84);
  backdrop-filter: blur(12px);
}

.win-overlay button {
  color: #1a1008;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd36d, #ff934d);
}

@media (max-width: 520px) {
  body {
    justify-content: flex-start;
    padding: 10px;
    gap: 0;
  }

  h1 {
    font-size: clamp(1.6rem, 8vw, 2.1rem);
    line-height: 1;
    margin-bottom: 4px;
  }

  .subtitle {
    margin-bottom: 10px;
    font-size: 0.78rem;
    text-align: center;
  }

  .controls {
    gap: 6px;
    margin-bottom: 10px;
  }

  .controls button,
  .controls select {
    flex: 1 1 96px;
    min-width: 0;
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .stats {
    gap: 6px;
    margin-bottom: 10px;
  }

  .stats div {
    padding: 7px 6px;
  }

  .stats span {
    font-size: 0.62rem;
    letter-spacing: 0.04em;
  }

  .stats strong {
    font-size: 1rem;
  }

  .board-container {
    padding: 8px;
    border-radius: 14px;
  }

  .board {
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
  }

  .tile {
    border-radius: 8px;
  }
}
