/* ========================================================================
   SpellingMasters — shared design system
   Built from the Week 33 reference: gradient sky background, Comic Sans
   typography, 3D stacked button shadows, vibrant team colors, rounded
   cards. Reused across student, teacher, and admin surfaces.
   ======================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  min-height: 100%;
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Trebuchet MS', system-ui, sans-serif;
  background: linear-gradient(135deg, #6dd5ed 0%, #98e4ff 50%, #b8f3ff 100%);
  color: #2c3e50;
}

body.app-shell { overflow: hidden; }
body.dashboard  { min-height: 100vh; padding-bottom: 40px; }

a { color: inherit; }
button { font-family: inherit; }

:root {
  --c-primary:   #3498db;
  --c-success:   #27ae60;
  --c-danger:    #e74c3c;
  --c-warning:   #e67e22;
  --c-accent:    #9b59b6;
  --c-accent-2:  #16a085;
  --c-gold:      #ffd700;
  --c-pink:      #ff6b9d;
  --c-text:      #2c3e50;
  --c-muted:     #7f8c8d;
  --c-bg-card:   #ffffff;
}

/* ---- Top bar (in-game) ---- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 78px;
  background: rgba(255,255,255,0.95);
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  display: flex; align-items: center; padding: 0 22px;
  z-index: 100; gap: 14px;
}
.topbar .title-now { flex: 1; text-align: center; font-size: 26px; font-weight: bold; color: var(--c-text); }
.topbar .word-counter { font-size: 16px; color: var(--c-muted); margin-left: 12px; }

.home-btn {
  background: var(--c-pink); color: white; border: none;
  padding: 12px 22px; border-radius: 14px;
  font-size: 22px; font-weight: bold; cursor: pointer;
  box-shadow: 0 4px 0 #d14679; transition: transform 0.1s, box-shadow 0.1s;
}
.home-btn:hover { transform: translateY(2px); box-shadow: 0 2px 0 #d14679; }

/* ---- Buttons (3D stack) ---- */
.btn {
  border: none; padding: 12px 22px; border-radius: 14px;
  font-size: 18px; font-weight: bold; cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,0.2);
  transition: transform 0.1s, box-shadow 0.1s;
  background: white; color: var(--c-text);
}
.btn:hover  { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.2); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary { background: var(--c-primary); color: white; box-shadow: 0 4px 0 #21618c; }
.btn-primary:hover { box-shadow: 0 2px 0 #21618c; }
.btn-success { background: var(--c-success); color: white; box-shadow: 0 4px 0 #196f3d; }
.btn-success:hover { box-shadow: 0 2px 0 #196f3d; }
.btn-danger  { background: var(--c-danger);  color: white; box-shadow: 0 4px 0 #922b21; }
.btn-danger:hover  { box-shadow: 0 2px 0 #922b21; }
.btn-warning { background: var(--c-warning); color: white; box-shadow: 0 4px 0 #af6109; }
.btn-warning:hover { box-shadow: 0 2px 0 #af6109; }
.btn-accent  { background: var(--c-accent);  color: white; box-shadow: 0 4px 0 #6c3483; }
.btn-accent:hover  { box-shadow: 0 2px 0 #6c3483; }
.btn-ghost   { background: #ecf0f1; color: var(--c-text); box-shadow: 0 4px 0 #bdc3c7; }
.btn-ghost:hover   { box-shadow: 0 2px 0 #bdc3c7; }
.btn-lg { padding: 16px 28px; font-size: 22px; }
.btn-sm { padding: 8px 14px; font-size: 14px; box-shadow: 0 3px 0 rgba(0,0,0,0.15); }

/* ---- Layout / Card / Grid ---- */
.container { max-width: 1280px; margin: 0 auto; padding: 24px 20px; }
.container-narrow { max-width: 760px; margin: 0 auto; padding: 24px 20px; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 12px; flex-wrap: wrap;
}
.page-header h1 {
  font-size: 36px; color: var(--c-text);
  text-shadow: 3px 3px 0 #fff;
}
.page-header .header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card {
  background: var(--c-bg-card); border-radius: 20px; padding: 22px 24px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.08), 0 10px 24px rgba(0,0,0,0.08);
  margin-bottom: 18px;
}
.card-title { font-size: 22px; color: var(--c-text); margin-bottom: 12px; }

.big-title {
  text-align: center; font-size: 56px;
  color: var(--c-text);
  text-shadow: 4px 4px 0 #fff, 8px 8px 0 rgba(0,0,0,0.1);
  margin-bottom: 8px;
}
.subtitle { text-align: center; font-size: 20px; color: #34495e; margin-bottom: 24px; }

.grid-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.game-card {
  background: white; border-radius: 20px; padding: 20px 16px;
  text-align: center; cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,0.12), 0 10px 24px rgba(0,0,0,0.08);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  border: 4px solid transparent;
  text-decoration: none; color: inherit;
  display: block;
}
.game-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 0 rgba(0,0,0,0.12), 0 16px 32px rgba(0,0,0,0.12);
  border-color: var(--c-gold);
}
.game-card .icon { font-size: 64px; line-height: 1; margin-bottom: 8px; }
.game-card h3 { font-size: 22px; color: var(--c-text); margin-bottom: 6px; }
.game-card p  { font-size: 13px; color: var(--c-muted); line-height: 1.3; }

.badge {
  display: inline-block; font-size: 11px;
  padding: 3px 10px; border-radius: 10px; font-weight: bold;
  background: var(--c-success); color: white;
}
.badge.new      { background: var(--c-danger); }
.badge.host     { background: var(--c-accent); }
.badge.locked   { background: #95a5a6; }
.badge.draft    { background: #95a5a6; }
.badge.published{ background: var(--c-success); }
.badge.gold     { background: var(--c-gold); color: #5a4500; }

/* ---- Forms ---- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; color: var(--c-text); margin-bottom: 4px; font-weight: bold; }
.field input,
.field select,
.field textarea {
  width: 100%; padding: 10px 14px; border-radius: 12px;
  border: 2px solid #ecf0f1; background: white;
  font-family: inherit; font-size: 16px; color: var(--c-text);
}
.field input:focus,
.field select:focus,
.field textarea:focus { outline: none; border-color: var(--c-primary); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-error { color: var(--c-danger); font-size: 13px; margin-top: 4px; }
.field-help  { color: var(--c-muted); font-size: 13px; margin-top: 4px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; background: white; border-radius: 16px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
table.data {
  width: 100%; border-collapse: collapse; font-size: 15px;
}
table.data th, table.data td { padding: 12px 16px; text-align: left; }
table.data thead { background: #f8f9fa; }
table.data th { font-size: 13px; text-transform: uppercase; color: var(--c-muted); letter-spacing: 0.5px; }
table.data tbody tr { border-top: 1px solid #ecf0f1; }
table.data tbody tr:hover { background: #fafbfc; }
table.data td.actions { white-space: nowrap; }
table.data .empty-row { text-align: center; color: var(--c-muted); padding: 28px; }

/* ---- Nav (dashboard sidebar/topbar) ---- */
.dash-nav {
  background: rgba(255,255,255,0.95);
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  padding: 12px 22px;
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
  position: sticky; top: 0; z-index: 50;
}
.dash-nav .brand {
  font-size: 22px; font-weight: bold; color: var(--c-text);
  margin-right: 12px;
}
.dash-nav .nav-link {
  padding: 8px 14px; border-radius: 10px; text-decoration: none;
  color: var(--c-text); font-weight: bold; font-size: 15px;
}
.dash-nav .nav-link:hover { background: #ecf0f1; }
.dash-nav .nav-link.active { background: var(--c-primary); color: white; }
.dash-nav .spacer { flex: 1; }
.dash-nav .user-chip {
  background: #ecf0f1; padding: 8px 14px; border-radius: 10px;
  font-size: 14px; color: var(--c-text);
}

/* ---- Login card ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: white; border-radius: 28px; padding: 36px 40px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.18);
  max-width: 460px; width: 100%;
  border: 6px solid var(--c-gold);
}
.login-card h1 { font-size: 36px; text-align: center; margin-bottom: 4px; }
.login-card .subtitle { font-size: 16px; margin-bottom: 20px; }
.role-tabs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.role-tab {
  padding: 10px 8px; border: 3px solid #ecf0f1; border-radius: 12px;
  background: white; font-weight: bold; cursor: pointer; font-family: inherit; font-size: 14px;
  color: var(--c-text);
}
.role-tab.active { border-color: var(--c-primary); background: #ebf5fb; color: var(--c-primary); }

/* ---- Toast + confetti (carried over) ---- */
.toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 60px; font-weight: bold;
  text-shadow: 3px 3px 0 white, -3px -3px 0 white, 3px -3px 0 white, -3px 3px 0 white;
  z-index: 9000; pointer-events: none;
  animation: toastIn 1.2s ease-out forwards;
}
@keyframes toastIn {
  0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  30%  { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  70%  { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.9); opacity: 0; }
}
.toast.good { color: var(--c-success); }
.toast.bad  { color: var(--c-danger); }

.confetti {
  position: fixed; width: 14px; height: 14px;
  z-index: 8999; pointer-events: none;
}

.flash-banner {
  background: #fff8dc; border: 2px solid var(--c-gold); border-radius: 14px;
  padding: 12px 18px; margin-bottom: 18px; color: #5a4500;
}
.flash-banner.error { background: #fadbd8; border-color: var(--c-danger); color: #922b21; }
.flash-banner.success { background: #d4f4d4; border-color: var(--c-success); color: #196f3d; }

/* ---- Score / KPI tiles ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi  { background: white; border-radius: 16px; padding: 18px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.kpi .label { font-size: 13px; color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.kpi .value { font-size: 32px; font-weight: bold; color: var(--c-text); margin-top: 4px; }
.kpi .delta { font-size: 13px; color: var(--c-success); margin-top: 4px; }

/* ---- Game shell (in-game wrapper) ---- */
.game-shell {
  position: absolute; inset: 78px 0 0 0;
  padding: 20px;
  overflow: auto;
}
.game-end-card {
  background: white; border-radius: 28px; padding: 40px 56px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  text-align: center; max-width: 600px; margin: 40px auto;
  border: 6px solid var(--c-gold);
}
.game-end-card .score-big { font-size: 110px; color: var(--c-gold); text-shadow: 4px 4px 0 #b7950b; line-height: 1; }
.game-end-card h2 { font-size: 36px; margin: 14px 0 8px; }
.game-end-card p  { font-size: 18px; color: var(--c-muted); margin-bottom: 22px; }

/* ---- Responsive ---- */
@media (max-width: 720px) {
  .field-row { grid-template-columns: 1fr; }
  .big-title { font-size: 40px; }
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; }
  .game-shell { inset: 110px 0 0 0; }
}
