/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --surface: #14141f;
  --border: #2a2a3a;
  --pink: #ff2d78;
  --cyan: #00e5ff;
  --gold: #ffd700;
  --text: #e8e8f0;
  --text-dim: #8888aa;
  --correct: #538d4e;
  --present: #b59f3b;
  --absent: #3a3a4c;
  --cell-size: 56px;
  --gap: 5px;
}

body {
  font-family: 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

/* ===== Header ===== */
.header {
  text-align: center;
  padding: 16px 8px 8px;
  width: 100%;
  max-width: 440px;
}
.header h1 {
  font-size: 1.6rem;
  background: linear-gradient(135deg, var(--pink), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
}
.header .subtitle {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ===== Game Area ===== */
.game-area {
  position: relative;
  margin: 8px 0;
}

.board {
  display: grid;
  grid-template-rows: repeat(6, var(--cell-size));
  grid-template-columns: repeat(5, var(--cell-size));
  gap: var(--gap);
  padding: 4px;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text);
  background: transparent;
  transition: border-color 0.15s;
}

.cell.filled {
  border-color: #555;
  animation: cellPop 0.1s ease;
}

@keyframes cellPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.cell.reveal {
  animation: flipReveal 0.5s ease forwards;
}

@keyframes flipReveal {
  0% {
    transform: rotateX(0deg);
  }
  50% {
    transform: rotateX(90deg);
  }
  100% {
    transform: rotateX(0deg);
  }
}

.cell.correct {
  background: var(--correct);
  border-color: var(--correct);
  color: #fff;
}

.cell.present {
  background: var(--present);
  border-color: var(--present);
  color: #fff;
}

.cell.absent {
  background: var(--absent);
  border-color: var(--absent);
  color: #888;
}

/* Bounce on win */
.cell.win-bounce {
  animation: winBounce 0.5s ease;
}
@keyframes winBounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-20px); }
  60% { transform: translateY(-10px); }
}

/* ===== Message Toast ===== */
.message {
  min-height: 28px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin: 4px 0;
  opacity: 0;
  transition: opacity 0.3s;
}
.message.show {
  opacity: 1;
}

/* ===== Overlay ===== */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 15, 0.9);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
  padding: 16px;
}
.overlay.active {
  opacity: 1;
  pointer-events: all;
}
.overlay h2 {
  font-size: 1.4rem;
  margin-bottom: 6px;
}
.overlay-word {
  font-size: 1.1rem;
  color: var(--cyan);
  margin-bottom: 8px;
  letter-spacing: 4px;
  font-weight: 700;
}
.overlay-stats {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 12px;
  text-align: center;
  line-height: 1.6;
}

/* ===== Buttons ===== */
.btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.btn:hover { border-color: var(--pink); background: #1a1a2e; }
.btn:active { transform: scale(0.95); }
.btn.primary {
  background: linear-gradient(135deg, var(--pink), #cc1155);
  border-color: var(--pink);
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.15); }
.overlay .btn { margin: 4px; }

/* ===== Keyboard ===== */
.keyboard {
  max-width: 500px;
  width: 100%;
  padding: 0 4px;
  margin: 4px 0;
}

.kb-row {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 4px;
}

.kb-row button {
  background: #555;
  border: none;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 30px;
  height: 50px;
  padding: 0 8px;
  cursor: pointer;
  transition: all 0.15s;
  flex: 1;
  max-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.kb-row button.wide {
  flex: 1.5;
  max-width: 65px;
  font-size: 0.65rem;
}

.kb-row button:hover { filter: brightness(1.3); }
.kb-row button:active { transform: scale(0.93); }

.kb-row button.correct {
  background: var(--correct);
  color: #fff;
}
.kb-row button.present {
  background: var(--present);
  color: #fff;
}
.kb-row button.absent {
  background: #222;
  color: #555;
}

/* ===== Patreon CTA ===== */
.patreon-cta {
  margin: 12px 0;
  text-align: center;
}
.patreon-cta a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #ff424d, #ff2d78);
  color: #fff;
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 24px;
  font-weight: 700;
  font-size: 0.85rem;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(255,45,120,0.3);
}
.patreon-cta a:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255,45,120,0.4); }
.patreon-cta .cta-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ===== How to Play ===== */
.how-to-play {
  max-width: 440px;
  width: 100%;
  padding: 0 16px;
  margin-bottom: 16px;
}
.how-to-play details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
.how-to-play summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--cyan);
  font-weight: 600;
}
.how-to-play .content {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 8px;
  line-height: 1.6;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 12px;
  color: var(--text-dim);
  font-size: 0.7rem;
  max-width: 440px;
}
.footer a { color: var(--pink); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ===== Responsive ===== */
@media (max-width: 380px) {
  :root {
    --cell-size: calc((100vw - 50px) / 5);
  }
  .header h1 { font-size: 1.3rem; }
  .kb-row button {
    height: 44px;
    font-size: 0.7rem;
    min-width: 24px;
  }
  .kb-row button.wide {
    font-size: 0.6rem;
  }
}

@media (min-width: 500px) {
  :root {
    --cell-size: 62px;
  }
  .kb-row button {
    height: 54px;
    font-size: 0.85rem;
  }
}
