/* ═══════════════════════════════════════════════════════
   Ghibli-inspired Auth + Dashboard styles
   ═══════════════════════════════════════════════════════ */

.hidden { display: none !important; }

/* ── Variables ──────────────────────────────────────────── */
:root {
  --g-sky:     #c9e8f5;
  --g-sky2:    #a8d5ec;
  --g-cream:   #f7f2e8;
  --g-paper:   #fdfaf4;
  --g-green:   #6aab6e;
  --g-green2:  #4a8b4e;
  --g-hill:    #8db87c;
  --g-amber:   #d4894a;
  --g-gold:    #c4973a;
  --g-dark:    #3b3228;
  --g-text:    #4a3f35;
  --g-muted:   #8a7f75;
  --g-shadow:  0 4px 20px rgba(60,50,40,0.12);
  --g-radius:  18px;
}

/* ── TG Monogram logotype ───────────────────────────────── */
.tg-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 0 14px;
}

.tg-logo {
  width: 140px;
  height: 140px;
  display: block;
  object-fit: contain;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 3px 16px rgba(0,0,0,0.30);
  padding: 10px;
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1);
}

.tg-logo:hover {
  transform: scale(1.06);
}

.tg-wordmark {
  margin: 0;
  font-family: 'Libre Baskerville', 'Baskerville Old Face', 'Baskerville', serif;
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--g-dark);
}
.tg-submark {
  margin: 0;
  font-family: 'Cormorant Garamond', 'Didot', serif;
  font-size: 0.72rem;
  font-weight: 300;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--g-muted);
}

/* ── Login page ─────────────────────────────────────────── */
.auth-body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Georgia', serif;
  background: var(--g-sky);
}

.auth-scene {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.8rem;
}

.auth-sky {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #acd6f0 0%, #ceeaf8 55%, #ddf0f5 100%);
  z-index: 0;
}

/* Clouds */
.auth-clouds { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
.auth-cloud {
  position: absolute;
  background: rgba(255,255,255,0.88);
  border-radius: 50px;
  filter: blur(2px);
}
.auth-cloud::before, .auth-cloud::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,0.88);
  border-radius: 50%;
}
.c1 { width: 180px; height: 50px; top: 12%; left: 8%; animation: cloudDrift 22s linear infinite; }
.c1::before { width: 90px; height: 70px; top: -30px; left: 25px; }
.c1::after  { width: 60px; height: 50px; top: -20px; left: 80px; }
.c2 { width: 240px; height: 60px; top: 22%; right: 10%; animation: cloudDrift 30s linear infinite reverse; }
.c2::before { width: 110px; height: 80px; top: -35px; left: 40px; }
.c2::after  { width: 80px;  height: 60px; top: -25px; left: 130px; }
.c3 { width: 140px; height: 40px; top: 6%;  left: 40%; animation: cloudDrift 18s linear infinite; }
.c3::before { width: 70px; height: 55px; top: -25px; left: 20px; }

@keyframes cloudDrift {
  from { transform: translateX(0); }
  to   { transform: translateX(60px); }
}

/* Rolling hills */
.auth-hills {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 220px;
  background: var(--g-hill);
  border-radius: 80% 80% 0 0 / 60px 60px 0 0;
  z-index: 1;
}
.auth-hills::before {
  content: '';
  position: absolute;
  bottom: 0; left: -10%; width: 55%;
  height: 180px;
  background: var(--g-green);
  border-radius: 80% 80% 0 0 / 50px 50px 0 0;
}
.auth-hills::after {
  content: '';
  position: absolute;
  bottom: 0; right: -5%; width: 50%;
  height: 160px;
  background: var(--g-green2);
  border-radius: 80% 80% 0 0 / 50px 50px 0 0;
}

/* Login card */
.auth-card {
  position: relative;
  z-index: 10;
  background: var(--g-paper);
  border-radius: var(--g-radius);
  padding: 0 1.8rem 1.2rem;
  width: 380px;
  max-width: 92vw;
  max-height: calc(100vh - 2rem);
  box-shadow: 0 8px 40px rgba(60,50,40,0.18), 0 2px 8px rgba(60,50,40,0.1);
  text-align: center;
  border: 1.5px solid rgba(196,151,58,0.25);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Hero watercolor — the first thing players see */
.auth-hero-frame {
  margin: 0 -1.8rem 0.75rem;
  overflow: hidden;
  position: relative;
  background: #aac5d0;
  flex: 0 0 auto;
  height: 36vh;
  max-height: 280px;
}
.auth-hero-img {
  width: 100%;
  height: 100%;
  /* Visa HELA målningen — moln upptill, hav i mitten, simmare nedtill.
     Bilden krymper proportionellt så att login-knapparna alltid får plats. */
  object-fit: contain;
  object-position: center;
  display: block;
}
.auth-hero-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(245,238,222,0.95) 100%);
  pointer-events: none;
}

/* Soft, blurred painting as the page backdrop */
.auth-scene--hero .auth-hero-bg {
  position: absolute;
  inset: 0;
  background: url('/images/login_hero.jpeg') center/cover no-repeat;
  filter: blur(28px) brightness(0.85) saturate(0.9);
  transform: scale(1.1);
  z-index: 0;
}
.auth-scene--hero { background: #6e8a98; }

.auth-logo-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 12px;
  margin-bottom: 0.6rem;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--g-dark);
  margin: 0 0 0.15rem;
  letter-spacing: 0.03em;
}

.auth-subtitle {
  font-size: 0.85rem;
  color: var(--g-muted);
  margin: 0 0 0.75rem;
  line-height: 1.4;
}

.auth-divider { margin: 0.5rem 0 0.45rem !important; }
.auth-teacher-link { margin-top: 0.6rem !important; }
.auth-guest-note { margin: 0.25rem 0 0; }

/* Ensure all login controls — including teacher link — are always reachable.
   Hero image compresses progressively on shorter screens. */
@media (max-height: 800px) {
  .auth-hero-frame { height: 30vh; max-height: 230px; }
  .tg-logo-wrap { padding: 12px 0 8px; }
}
@media (max-height: 680px) {
  .auth-hero-frame { height: 24vh; max-height: 170px; margin-bottom: 0.5rem; }
  .auth-title { font-size: 1.3rem; }
  .auth-subtitle { margin-bottom: 0.5rem; font-size: 0.8rem; }
  .auth-card { padding-bottom: 0.8rem; }
  .tg-logo-wrap { padding: 8px 0 6px; }
  .tg-logo { width: 72px; }
  .tg-wordmark { font-size: 1rem; }
}
@media (max-height: 560px) {
  .auth-hero-frame { height: 18vh; max-height: 120px; }
  .auth-subtitle { display: none; }
  .auth-guest-note { display: none; }
  .tg-logo { width: 56px; }
}

.auth-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  background: #fff;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  padding: 0.75rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--g-dark);
  text-decoration: none;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
}
.auth-google-btn:hover {
  box-shadow: 0 4px 16px rgba(60,50,40,0.14);
  border-color: #bbb;
  transform: translateY(-1px);
}
.auth-google-icon { width: 20px; height: 20px; flex-shrink: 0; }

.auth-error {
  background: #fdecea;
  border: 1px solid #f5c6c4;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.83rem;
  color: #c0392b;
  margin-bottom: 1rem;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.1rem 0 0.9rem;
  color: var(--g-muted);
  font-size: 0.8rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(0,0,0,0.12);
}

.auth-guest-btn {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.55);
  border: 2px dashed rgba(0,0,0,0.18);
  border-radius: 12px;
  font-size: 0.97rem;
  font-weight: 600;
  color: #5a6a4a;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  box-sizing: border-box;
}
.auth-guest-btn:hover {
  background: rgba(255,255,255,0.8);
  border-color: rgba(0,0,0,0.3);
}

.auth-guest-note {
  margin: 0.45rem 0 0;
  font-size: 0.75rem;
  color: var(--g-muted);
  text-align: center;
}

.auth-teacher-link {
  margin-top: 1.4rem;
  font-size: 0.8rem;
  color: var(--g-muted);
}
.auth-teacher-link a {
  color: var(--g-amber);
  text-decoration: none;
  font-weight: 600;
}
.auth-teacher-link a:hover { text-decoration: underline; }

/* Teacher access page */
.auth-teacher-card { max-width: 420px; }
.auth-form-group { text-align: left; margin-bottom: 1.1rem; }
.auth-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--g-dark);
  margin-bottom: 0.35rem;
  letter-spacing: 0.04em;
}
.auth-input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid #d8cfc4;
  border-radius: 9px;
  font-size: 0.93rem;
  background: #faf8f3;
  color: var(--g-dark);
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.auth-input:focus { border-color: var(--g-amber); }
.auth-submit-btn {
  width: 100%;
  padding: 0.78rem;
  background: linear-gradient(135deg, var(--g-amber), var(--g-gold));
  border: none;
  border-radius: 10px;
  font-size: 0.97rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  margin-top: 0.5rem;
}
.auth-submit-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.auth-back { margin-top: 1rem; font-size: 0.8rem; }
.auth-back a { color: var(--g-amber); text-decoration: none; }

/* ── Dashboard ──────────────────────────────────────────── */
.dash-body {
  margin: 0;
  min-height: 100vh;
  background: var(--g-cream);
  font-family: 'Georgia', serif;
  color: var(--g-text);
}

/* Decorative Ghibli topper */
.dash-topper {
  height: 80px;
  background: linear-gradient(180deg, #a8d5ec 0%, #c9e8f5 100%);
  position: relative;
  overflow: hidden;
}
.dash-topper-hills {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 50px;
  background: var(--g-hill);
  border-radius: 80% 80% 0 0 / 30px 30px 0 0;
}
.dash-topper-hills::before {
  content: '';
  position: absolute;
  bottom: 0; left: -5%; width: 40%; height: 40px;
  background: var(--g-green);
  border-radius: 80% 80% 0 0 / 25px 25px 0 0;
}
.dash-topper-hills::after {
  content: '';
  position: absolute;
  bottom: 0; right: -3%; width: 35%; height: 36px;
  background: var(--g-green2);
  border-radius: 80% 80% 0 0 / 22px 22px 0 0;
}

/* Header */
.dash-header {
  background: var(--g-paper);
  border-bottom: 1.5px solid rgba(196,151,58,0.18);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
}
.dash-header-left { display: flex; align-items: center; gap: 0.9rem; }
.dash-logo { width: 40px; height: 40px; border-radius: 8px; object-fit: contain; }
.dash-title { font-size: 1.2rem; font-weight: 700; color: var(--g-dark); }
.dash-subtitle { font-size: 0.75rem; color: var(--g-muted); }
.dash-header-right { display: flex; align-items: center; gap: 1rem; }
.dash-teacher-name { font-size: 0.88rem; color: var(--g-muted); }
.dash-game-panel-btn {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.4rem 0.9rem;
  border: 1.5px solid rgba(196,151,58,0.45);
  border-radius: 8px;
  text-decoration: none;
  color: var(--g-amber);
  background: rgba(196,151,58,0.08);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  white-space: nowrap;
}
.dash-game-panel-btn:hover {
  background: rgba(196,151,58,0.16);
  border-color: var(--g-amber);
  color: var(--g-dark);
}
@media (max-width: 640px) {
  .dash-game-panel-btn { display: none; }
}

.dash-logout-btn {
  font-size: 0.8rem;
  padding: 0.4rem 0.9rem;
  border: 1.5px solid #d8cfc4;
  border-radius: 8px;
  text-decoration: none;
  color: var(--g-muted);
  transition: border-color 0.2s, color 0.2s;
}
.dash-logout-btn:hover { border-color: var(--g-amber); color: var(--g-amber); }

/* Main */
.dash-main { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

/* Summary row */
.dash-summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.dash-summary-card {
  background: var(--g-paper);
  border-radius: 14px;
  padding: 1.2rem 1rem;
  text-align: center;
  box-shadow: var(--g-shadow);
  border: 1.5px solid rgba(196,151,58,0.15);
}
.dash-summary-num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--g-amber);
  line-height: 1;
  margin-bottom: 0.3rem;
}
.dash-summary-label { font-size: 0.78rem; color: var(--g-muted); font-style: italic; }

/* Filter bar */
.dash-filter-bar {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.dash-search {
  flex: 1;
  min-width: 200px;
  padding: 0.6rem 1rem;
  border: 1.5px solid #d8cfc4;
  border-radius: 10px;
  font-size: 0.9rem;
  background: var(--g-paper);
  color: var(--g-dark);
  outline: none;
  font-family: inherit;
}
.dash-search:focus { border-color: var(--g-amber); }
.dash-filter-select {
  padding: 0.6rem 1rem;
  border: 1.5px solid #d8cfc4;
  border-radius: 10px;
  font-size: 0.88rem;
  background: var(--g-paper);
  color: var(--g-dark);
  outline: none;
  cursor: pointer;
  font-family: inherit;
}

/* Student grid */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.2rem;
}
.dash-loading { color: var(--g-muted); font-style: italic; padding: 2rem; }

/* Student card */
.dash-student-card {
  background: var(--g-paper);
  border-radius: var(--g-radius);
  padding: 1.4rem 1.3rem 1.2rem;
  box-shadow: var(--g-shadow);
  border: 1.5px solid rgba(196,151,58,0.13);
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  position: relative;
  overflow: hidden;
}
.dash-student-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--g-green), var(--g-amber));
  border-radius: var(--g-radius) var(--g-radius) 0 0;
}
.dash-student-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(60,50,40,0.16);
}
.dash-card-top { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1rem; }
.dash-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 2.5px solid rgba(196,151,58,0.3);
  background: var(--g-sky);
}
.dash-avatar-fallback {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--g-green), var(--g-amber));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.dash-card-name { font-size: 0.97rem; font-weight: 700; color: var(--g-dark); }
.dash-card-email { font-size: 0.73rem; color: var(--g-muted); }
.dash-card-last { font-size: 0.7rem; color: var(--g-muted); margin-top: 0.2rem; font-style: italic; }

/* Game progress bars */
.dash-game-rows { display: flex; flex-direction: column; gap: 0.7rem; }
.dash-game-row {}
.dash-game-label {
  display: flex; justify-content: space-between;
  font-size: 0.75rem; color: var(--g-muted); margin-bottom: 0.25rem;
}
.dash-game-name { font-weight: 600; color: var(--g-text); }
.dash-progress-track {
  height: 8px; background: #ede8e0; border-radius: 99px; overflow: hidden;
}
.dash-progress-fill {
  height: 100%; border-radius: 99px;
  transition: width 0.6s cubic-bezier(.22,1,.36,1);
}
.fill-traitor     { background: linear-gradient(90deg, #7bb8d4, #4a8b9e); }
.fill-philosophy  { background: linear-gradient(90deg, #a8c4e8, #5a7fba); }
.fill-math        { background: linear-gradient(90deg, #a5c97a, #6aab6e); }
.fill-spelledaren { background: linear-gradient(90deg, #c9a8e8, #8a6dba); }
.fill-gruppspelet { background: linear-gradient(90deg, #f0c97a, #d99454); }
.fill-mord        { background: linear-gradient(90deg, #d48a8a, #a45656); }
.fill-roadtrip    { background: linear-gradient(90deg, #f4a78a, #c96a4a); }

/* Active-now summary card highlight */
.dash-summary-card--active {
  border: 1.5px solid rgba(52, 168, 83, 0.4);
  background: rgba(52, 168, 83, 0.06);
}
.dash-summary-card--active .dash-summary-num { color: #2a7a3a; }

/* Section headings */
.dash-section-heading {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--g-muted);
  margin: 2rem 0 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1.5px solid rgba(120,100,60,0.12);
}
.dash-section-heading--active {
  color: #2a7a3a;
  border-bottom-color: rgba(52,168,83,0.25);
}

/* Active student card */
.dash-student-card--active {
  border-color: rgba(52, 168, 83, 0.4);
  box-shadow: 0 2px 12px rgba(52,168,83,0.08);
}
.dash-student-card--active::before {
  background: linear-gradient(135deg, rgba(52,168,83,0.12), rgba(52,168,83,0.04));
}

/* Active badge inside card */
.dash-active-badge {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: #2a7a3a;
  background: rgba(52,168,83,0.1);
  border: 1px solid rgba(52,168,83,0.25);
  border-radius: 99px;
  padding: 0.1rem 0.55rem;
}

/* Modal */
.dash-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(60,50,40,0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.dash-modal-overlay.hidden { display: none; }
.dash-modal {
  background: var(--g-paper);
  border-radius: var(--g-radius);
  padding: 2rem;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 60px rgba(60,50,40,0.22);
  position: relative;
}
.dash-modal-close {
  position: absolute; top: 1rem; right: 1rem;
  background: none; border: none; font-size: 1.1rem;
  cursor: pointer; color: var(--g-muted); padding: 0.2rem 0.5rem;
  border-radius: 6px; transition: background 0.15s;
}
.dash-modal-close:hover { background: #ede8e0; }
.dash-modal-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.dash-modal-avatar { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; }
.dash-modal-name { font-size: 1.1rem; font-weight: 700; color: var(--g-dark); }
.dash-modal-email { font-size: 0.8rem; color: var(--g-muted); }

/* Modal session table */
.dash-modal-section { margin-bottom: 1.5rem; }
.dash-modal-section-title {
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em;
  color: var(--g-amber); text-transform: uppercase;
  border-bottom: 1.5px solid rgba(196,151,58,0.2);
  padding-bottom: 0.4rem; margin-bottom: 0.8rem;
}
.dash-session-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.dash-session-table th {
  text-align: left; padding: 0.3rem 0.5rem;
  color: var(--g-muted); font-weight: 600; font-size: 0.73rem;
}
.dash-session-table td { padding: 0.4rem 0.5rem; border-top: 1px solid #ede8e0; color: var(--g-text); }
.dash-session-table tr:hover td { background: #f7f2e8; }
.badge-won   { color: #3a8a4a; font-weight: 700; }
.badge-lost  { color: #b05a3a; }
.badge-score { color: var(--g-amber); font-weight: 700; }

/* No-data state */
.dash-empty {
  text-align: center; padding: 3rem 1rem;
  color: var(--g-muted); font-style: italic; font-size: 0.92rem;
}
