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

:root {
  --pink: #e8547c;
  --pink-light: #f7c5d0;
  --pink-soft: #fde8ed;
  --red: #c9374a;
  --red-dark: #9b2335;
  --cream: #fdf6f0;
  --white: #ffffff;
  --rose-gold: #b76e79;
  --rose-gold-light: #d4a0a8;
  --gray-dark: #333333;
  --gray-med: #666666;
  --gray-light: #999999;
  --gray-border: #ddd;
  --green: #6aaa64;
  --green-dark: #538d4e;
  --yellow: #c9b458;
  --yellow-dark: #b59f3b;
  --tile-gray: #787c7e;
  --absent: #787c7e;
  /* Connections colors */
  --conn-yellow: #f9df6d;
  --conn-green: #a0c35a;
  --conn-blue: #b0c4ef;
  --conn-purple: #ba81c5;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  background: var(--cream);
  color: var(--gray-dark);
  min-height: 100vh;
  line-height: 1.5;
}

/* ========== TYPOGRAPHY ========== */
h1, h2, h3 {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-weight: 700;
}

/* ========== HEADER ========== */
.site-header {
  text-align: center;
  padding: 1.5rem 1rem 1rem;
  border-bottom: 2px solid var(--pink-light);
  background: var(--white);
}

.site-header h1 {
  font-size: 1.75rem;
  color: var(--red-dark);
  letter-spacing: 0.02em;
}

.site-header .subtitle {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 0.85rem;
  color: var(--rose-gold);
  margin-top: 0.25rem;
  font-weight: 400;
}

/* ========== BACK LINK ========== */
.back-link {
  display: inline-block;
  margin: 1rem;
  color: var(--rose-gold);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}
.back-link:hover { color: var(--pink); }

/* ========== HUB GRID ========== */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1.25rem;
}

.game-tile {
  background: var(--white);
  border: 2px solid var(--pink-light);
  border-radius: 12px;
  padding: 2rem 1.5rem;
  text-align: center;
  text-decoration: none;
  color: var(--gray-dark);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  position: relative;
  cursor: pointer;
  display: block;
}

.game-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(232, 84, 124, 0.15);
  border-color: var(--pink);
}

.game-tile .tile-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.game-tile .tile-title {
  font-family: 'Georgia', serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--red-dark);
  margin-bottom: 0.35rem;
}

.game-tile .tile-desc {
  font-size: 0.85rem;
  color: var(--gray-med);
}

.game-tile.completed {
  border-color: var(--green);
  background: linear-gradient(135deg, var(--white) 0%, #f0faf0 100%);
}

.game-tile.completed::after {
  content: '\2713';
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: var(--green);
  color: white;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}

/* Finale tile */
#finale-tile {
  border-color: var(--rose-gold-light);
  background: linear-gradient(135deg, var(--pink-soft) 0%, var(--white) 100%);
  animation: finale-glow 2s ease-in-out infinite alternate;
}

#finale-tile.unlocked {
  animation: finale-appear 0.6s ease-out;
}

@keyframes finale-glow {
  from { box-shadow: 0 0 8px rgba(183, 110, 121, 0.2); }
  to   { box-shadow: 0 0 20px rgba(183, 110, 121, 0.4); }
}

@keyframes finale-appear {
  from { opacity: 0; transform: scale(0.8) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ========== GAME CONTAINERS ========== */
.game-container {
  max-width: 500px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  text-align: center;
}

.game-title {
  font-size: 1.4rem;
  color: var(--red-dark);
  margin: 1rem 0 0.5rem;
}

/* ========== WORDLE ========== */
.wordle-board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 5px;
  max-width: 330px;
  margin: 1rem auto;
}

.wordle-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.wordle-cell {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--gray-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  text-transform: uppercase;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  background: var(--white);
  transition: transform 0.1s;
}

.wordle-cell.filled {
  border-color: var(--gray-med);
  animation: pop 0.1s ease;
}

.wordle-cell.correct {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.wordle-cell.present {
  background: var(--yellow);
  border-color: var(--yellow);
  color: white;
}

.wordle-cell.absent {
  background: var(--absent);
  border-color: var(--absent);
  color: white;
}

.wordle-cell.flip {
  animation: flip 0.5s ease forwards;
}

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

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

/* Keyboard */
.keyboard {
  max-width: 500px;
  margin: 0.75rem auto 0;
  user-select: none;
}

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

.key {
  height: 52px;
  min-width: 32px;
  padding: 0 6px;
  border: none;
  border-radius: 4px;
  background: #d3d6da;
  color: var(--gray-dark);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  transition: background 0.15s;
  font-family: inherit;
}

.key.wide { min-width: 60px; font-size: 0.75rem; }
.key.correct { background: var(--green); color: white; }
.key.present { background: var(--yellow); color: white; }
.key.absent  { background: var(--absent); color: white; }

/* ========== CONNECTIONS ========== */
.connections-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-width: 480px;
  margin: 1rem auto;
}

.conn-tile {
  padding: 0.9rem 0.5rem;
  border: none;
  border-radius: 8px;
  background: #efefe6;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
  font-family: inherit;
  color: var(--gray-dark);
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  word-break: break-word;
}

.conn-tile:hover { transform: scale(1.03); }
.conn-tile.selected {
  background: var(--gray-dark);
  color: white;
}

.conn-solved {
  grid-column: 1 / -1;
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  color: var(--gray-dark);
  font-weight: 700;
  animation: solved-in 0.4s ease;
}

.conn-solved .category-name {
  font-size: 0.95rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.conn-solved .category-words {
  font-size: 0.8rem;
  font-weight: 600;
}

.conn-solved.yellow { background: var(--conn-yellow); }
.conn-solved.green  { background: var(--conn-green); }
.conn-solved.blue   { background: var(--conn-blue); }
.conn-solved.purple { background: var(--conn-purple); }

@keyframes solved-in {
  from { opacity: 0; transform: scaleY(0.5); }
  to   { opacity: 1; transform: scaleY(1); }
}

.conn-controls {
  margin: 0.75rem auto;
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.mistakes-display {
  font-size: 0.9rem;
  color: var(--gray-med);
}

.mistakes-dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 0.35rem;
}

.mistake-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gray-dark);
  display: inline-block;
  transition: opacity 0.3s;
}

.mistake-dot.used { opacity: 0.15; }

/* ========== CROSSWORD ========== */
.crossword-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  max-width: 500px;
  margin: 1rem auto;
}

.crossword-grid {
  display: grid;
  gap: 2px;
  width: fit-content;
}

.xw-cell {
  width: 52px;
  height: 52px;
  border: 2px solid var(--gray-dark);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  cursor: pointer;
}

.xw-cell.black {
  background: var(--gray-dark);
  border-color: var(--gray-dark);
  cursor: default;
}

.xw-cell .cell-number {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 0.6rem;
  color: var(--gray-dark);
  font-weight: 600;
  line-height: 1;
}

.xw-cell input {
  width: 100%;
  height: 100%;
  border: none;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  text-transform: uppercase;
  background: transparent;
  caret-color: transparent;
  outline: none;
  font-family: inherit;
  color: var(--gray-dark);
}

.xw-cell.focused {
  background: var(--conn-yellow);
}

.xw-cell.highlighted {
  background: #fffde0;
}

.xw-cell.correct-cell {
  background: var(--green);
}

.xw-cell.correct-cell input {
  color: white;
}

.clues-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  text-align: left;
  width: 100%;
}

.clues-section h3 {
  font-size: 0.95rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: var(--red-dark);
  font-family: 'Georgia', serif;
}

.clue-item {
  font-size: 0.85rem;
  color: var(--gray-dark);
  margin-bottom: 0.35rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: background 0.15s;
}

.clue-item:hover { background: var(--pink-soft); }
.clue-item.active-clue { background: var(--conn-yellow); font-weight: 600; }
.clue-item .clue-num { font-weight: 700; margin-right: 0.25rem; }

/* ========== BUTTONS ========== */
.btn {
  padding: 0.65rem 1.5rem;
  border: none;
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--pink);
  color: white;
}
.btn-primary:hover { background: var(--red); }
.btn-primary:disabled {
  background: var(--gray-light);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-dark);
  border: 2px solid var(--gray-border);
}
.btn-secondary:hover { border-color: var(--pink); color: var(--pink); }

/* ========== MODAL / MESSAGE OVERLAY ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  background: var(--white);
  border-radius: 16px;
  padding: 2rem;
  max-width: 380px;
  width: 90%;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-card h2 {
  color: var(--red-dark);
  margin-bottom: 0.75rem;
}

.modal-card p {
  color: var(--gray-med);
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

/* ========== TOAST ========== */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--gray-dark);
  color: white;
  padding: 0.6rem 1.25rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ========== FINALE ========== */
.finale-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  text-align: center;
}

.love-letter {
  background: var(--white);
  border: 2px solid var(--pink-light);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  margin: 2rem auto;
  text-align: left;
  line-height: 1.8;
  font-size: 1rem;
  color: var(--gray-dark);
  max-width: 520px;
  box-shadow: 0 4px 20px rgba(232, 84, 124, 0.1);
}

.love-letter .letter-greeting {
  font-family: 'Georgia', serif;
  font-size: 1.15rem;
  color: var(--red-dark);
  margin-bottom: 1rem;
}

.love-letter .letter-sign {
  margin-top: 1.5rem;
  font-family: 'Georgia', serif;
  color: var(--rose-gold);
  font-style: italic;
}

.finale-photo {
  max-width: 100%;
  border-radius: 12px;
  margin: 1.5rem auto;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

/* Confetti canvas */
#confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

/* ========== CATEGORY REVEAL (Connections) ========== */
.category-reveal {
  max-width: 480px;
  margin: 1.5rem auto;
  text-align: left;
}

.reveal-item {
  background: var(--white);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  border-left: 4px solid var(--gray-border);
}

.reveal-item.yellow { border-left-color: var(--conn-yellow); }
.reveal-item.green  { border-left-color: var(--conn-green); }
.reveal-item.blue   { border-left-color: var(--conn-blue); }
.reveal-item.purple { border-left-color: var(--conn-purple); }

.reveal-item .reveal-cat {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.15rem;
}

.reveal-item .reveal-desc {
  font-size: 0.8rem;
  color: var(--gray-med);
  font-style: italic;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 480px) {
  .site-header h1 { font-size: 1.4rem; }
  .hub-grid { gap: 0.75rem; padding: 0 0.75rem; }
  .game-tile { padding: 1.5rem 1rem; }

  .wordle-cell { font-size: 1.4rem; }
  .key { height: 46px; min-width: 26px; font-size: 0.75rem; }
  .key.wide { min-width: 48px; font-size: 0.65rem; }

  .conn-tile { padding: 0.65rem 0.35rem; font-size: 0.75rem; min-height: 44px; }

  .xw-cell { width: 44px; height: 44px; }
  .xw-cell input { font-size: 1.2rem; }
  .clues-panel { grid-template-columns: 1fr; }

  .love-letter { padding: 1.5rem 1.25rem; }
}

@media (max-width: 360px) {
  .wordle-board { max-width: 280px; }
  .wordle-cell { font-size: 1.2rem; }
  .key { height: 40px; min-width: 22px; font-size: 0.7rem; }
  .xw-cell { width: 38px; height: 38px; }
  .xw-cell input { font-size: 1rem; }
  .conn-tile { font-size: 0.7rem; }
}
