:root {
  --color-gold: #d9a327;
  --color-gold-dark: #b4861b;
  --color-gold-light: #f0c75e;
  --color-diamond: #1e81b0;
  --color-diamond-dark: #156082;
  --color-diamond-light: #5eaed4;
  --color-neutral: #d2b48c;
  --color-assassin: #1a1a1a;
  --color-card-bg: #fdf6e3;
  --color-bg: #f0ede6;
  --color-text: #334155;
  --transition-speed: 0.6s;
  --font-main: 'Space Grotesk', sans-serif;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--color-bg);
  color: var(--color-text);
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ====== HEADER ====== */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  z-index: 10;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--color-gold), var(--color-gold-dark));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center; color: white;
}
.title-group h1 { font-size: 1.4rem; font-weight: 800; letter-spacing: 3px; color: var(--color-text); }
.header-actions { display: flex; align-items: center; gap: 12px; }

/* ====== TURN BAR ====== */
.turn-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 24px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.turn-indicator {
  display: flex; align-items: center; gap: 12px;
  font-weight: 700; padding: 6px 16px; border-radius: 8px;
  border: 2px solid transparent;
  transition: all 0.3s;
}
.turn-text { font-size: 0.9rem; font-weight: 800; }
.timer {
  font-family: 'Space Grotesk', monospace; font-size: 1.2rem; font-weight: 700;
  background: #f1f5f9; padding: 3px 10px; border-radius: 6px;
}
.guess-info {
  font-weight: 700; font-size: 0.85rem; color: #64748b;
  background: #f1f5f9; padding: 4px 12px; border-radius: 6px;
}

/* ====== CLUE AREA ====== */
.clue-area-central {
  display: flex; justify-content: center; align-items: center;
  padding: 6px 16px; flex-shrink: 0;
}

.clue-bubble {
  display: flex; align-items: center; gap: 12px;
  background: white; padding: 8px 24px; border-radius: 50px;
  border: 3px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.clue-text { font-size: 1.3rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.clue-count-badge {
  background: #334155; color: white;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-weight: 700; font-size: 0.9rem;
}

.clue-input-group {
  display: flex; gap: 8px; align-items: center;
}
.clue-input {
  padding: 8px 14px; border: 2px solid #cbd5e1; border-radius: 8px;
  font-family: inherit; font-weight: 600; font-size: 0.9rem;
  outline: none; width: 160px; background: white; color: var(--color-text);
}
.clue-input:focus { border-color: var(--color-gold); }
.clue-select {
  padding: 8px; border: 2px solid #cbd5e1; border-radius: 8px;
  font-family: inherit; font-weight: 700; width: 50px; background: white; color: var(--color-text);
}

/* ====== MAIN LAYOUT ====== */
.game-board-container {
  display: flex;
  flex: 1;
  padding: 8px 16px 16px;
  gap: 16px;
  overflow: hidden;
}

/* ====== SIDEBARS ====== */
.sidebar {
  width: 220px;
  display: flex; flex-direction: column; gap: 12px;
}

.team-card {
  padding: 20px; border-radius: 12px;
  color: white; text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.team-card.gold { background: var(--color-gold); }
.team-card.diamond { background: var(--color-diamond); }

.team-header h2 { font-size: 0.85rem; letter-spacing: 2px; margin-bottom: 8px; opacity: 0.9; }
.team-icon-large { display: none; }
.team-score-box {
  background: rgba(0,0,0,0.15); padding: 12px; border-radius: 8px;
}
.score-value { font-size: 3.5rem; font-weight: 800; display: block; line-height: 1; }
.score-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; opacity: 0.8; margin-top: 4px; display: block; }
.team-status { font-size: 0.7rem; margin-top: 8px; opacity: 0.7; }

.panel {
  background: white; padding: 12px; border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.panel h3 { font-size: 0.8rem; color: #64748b; margin-bottom: 6px; }
.stat-row {
  display: flex; justify-content: space-between;
  padding: 5px 0; font-size: 0.85rem; font-weight: 600; color: var(--color-text);
}
.stat-row.danger strong { color: #dc2626; }

#noteArea {
  width: 100%; height: 80px;
  border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 8px; font-family: inherit; font-size: 0.8rem;
  resize: none; background: #fafafa; color: var(--color-text);
}

/* ====== BOARD GRID ====== */
.board-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 10px;
  max-height: 100%;
  aspect-ratio: 5/4;
  margin: auto;
}

/* ====== CARDS ====== */
.card-container {
  perspective: 1000px; cursor: pointer;
  width: 100%; height: 100%;
}

.card-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform var(--transition-speed);
  transform-style: preserve-3d;
  border-radius: 10px;
}

.card-container:hover .card-inner {
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}
.card-container.flipped .card-inner { transform: rotateY(180deg); }

.card-front, .card-back {
  position: absolute; width: 100%; height: 100%;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 10px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px;
}

.card-front {
  background: var(--color-card-bg);
  border: 2px solid #e8dcc8;
  box-shadow: 0 3px 6px rgba(0,0,0,0.08);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.word {
  font-size: 1rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #1e293b; word-break: break-word;
  text-align: center;
}

/* Card Backs */
.card-back {
  transform: rotateY(180deg);
  color: white; position: relative;
  gap: 4px;
}
.card-back.red { background: var(--color-gold); }
.card-back.blue { background: var(--color-diamond); }
.card-back.neutral { background: var(--color-neutral); color: #3d3d3d; }
.card-back.shadow { background: var(--color-assassin); }

.word-revealed {
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  opacity: 0.8; word-break: break-word;
  text-align: center;
}
.role-icon { font-size: 1.8rem; }

/* Colorblind Symbols */
.card-back.red::after { content: "\2726"; position: absolute; top: 5px; right: 8px; font-size: 1rem; opacity: 0.5; }
.card-back.blue::after { content: "\25C6"; position: absolute; top: 5px; right: 8px; font-size: 1rem; opacity: 0.5; }
.card-back.neutral::after { content: "\25CB"; position: absolute; top: 5px; right: 8px; font-size: 1rem; opacity: 0.5; }
.card-back.shadow::after { content: "\2715"; position: absolute; top: 5px; right: 8px; font-size: 1rem; opacity: 0.7; }

/* ====== SPYMASTER HINTS ====== */
/* Codenames style: show colored border instead of flipping */
.card-container.hint-red .card-front { border: 4px solid var(--color-gold); background: #fef9ed; }
.card-container.hint-blue .card-front { border: 4px solid var(--color-diamond); background: #eef7fb; }
.card-container.hint-neutral .card-front { border: 4px solid var(--color-neutral); background: #faf5ee; }
.card-container.hint-shadow .card-front { border: 4px solid var(--color-assassin); background: #f1f1f1; }

/* ====== BUTTONS ====== */
.btn {
  padding: 8px 18px; border-radius: 8px;
  font-weight: 700; cursor: pointer; border: none;
  font-family: inherit; font-size: 0.8rem;
  transition: all 0.2s; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.btn.primary { background: #334155; color: white; }
.btn.primary:hover { background: #1e293b; }
.btn.secondary { background: #e2e8f0; color: #334155; }
.btn.secondary:hover { background: #cbd5e1; }
.btn.small { padding: 6px 12px; font-size: 0.75rem; }
.btn.ghost { background: transparent; border: 1px solid #cbd5e1; color: #64748b; }
.btn.ghost:hover { border-color: #94a3b8; background: #f8fafc; }
.btn.full-width { width: 100%; }
.btn-icon { background: none; border: none; cursor: pointer; color: #64748b; padding: 6px; }
.btn-icon:hover { color: #334155; }

/* ====== TOGGLES ====== */
.toggle-switch { display: flex; align-items: center; }
.switch-label {
  position: relative; display: inline-block;
  width: 40px; height: 22px;
  background: #cbd5e1; border-radius: 20px; cursor: pointer;
  transition: background 0.3s;
}
.slider {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: white; border-radius: 50%;
  transition: 0.3s;
}
input[type="checkbox"] { display: none; }
input:checked + .switch-label { background: #475569; }
input:checked + .switch-label .slider { transform: translateX(18px); }
.label-text { margin-left: 50px; font-size: 0.8rem; font-weight: 600; color: #64748b; white-space: nowrap; }

/* ====== MODALS ====== */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal-content {
  background: white; padding: 32px; border-radius: 16px;
  max-width: 450px; width: 90%; text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}
.modal-content h2 { font-size: 1.4rem; margin-bottom: 8px; }
.modal-content p { color: #64748b; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.setting-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; }

/* ====== RESPONSIVE ====== */
@media (max-width: 1024px) {
  .game-board-container { flex-direction: column; height: auto; overflow-y: auto; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .team-card { flex: 1; min-width: 140px; }
  .board-grid { min-height: 300px; aspect-ratio: 1/1; }
}
