/* ============================================================
   SPELLING FUN — Global Design System
   Ocean Gradient · Frosted Glass · Space Grotesk
   Reception → Year 6 · Dyslexia-friendly
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Nunito:wght@700;800;900&display=swap');

/* Lexie Readable — dyslexia-friendly body font */
@font-face {
  font-family: 'LexieReadable';
  src: url('https://cdn.jsdelivr.net/gh/k-type/lexie-readable@main/fonts/LexieReadable-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'LexieReadable';
  src: url('https://cdn.jsdelivr.net/gh/k-type/lexie-readable@main/fonts/LexieReadable-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Ocean palette */
  --color-deep:       #0047AB;
  --color-mid:        #0066CC;
  --color-bright:     #00B4D8;
  --color-light:      #48CAE4;
  --color-ice:        #ADE8F4;

  /* Accent */
  --color-gold:       #FFD166;
  --color-gold-dark:  #E5B800;
  --color-white:      #FFFFFF;
  --color-red:        #E63946;

  /* Glass surfaces */
  --glass-bg:         rgba(255,255,255,0.16);
  --glass-bg-strong:  rgba(255,255,255,0.22);
  --glass-border:     rgba(255,255,255,0.28);
  --glass-shadow:     0 8px 32px rgba(0,71,171,0.25);

  /* Card surfaces (for game-over etc.) */
  --surface-card:     rgba(255,255,255,0.96);

  /* Text */
  --text-on-ocean:    #ffffff;
  --text-muted:       rgba(255,255,255,0.65);
  --text-navy:        #00224D;

  /* Typography */
  --font-body:        'LexieReadable', 'Space Grotesk', sans-serif;
  --font-display:     'Space Grotesk', sans-serif;
  --font-number:      'Nunito', sans-serif;

  /* Dyslexia-friendly settings */
  --letter-spacing:   0.03em;
  --line-height:      1.6;
  --word-spacing:     0.1em;

  /* Spacing */
  --space-xs:  6px;
  --space-sm:  12px;
  --space-md:  20px;
  --space-lg:  32px;
  --space-xl:  48px;

  /* Radius */
  --radius-sm:   8px;
  --radius-md:   16px;
  --radius-lg:   24px;
  --radius-xl:   32px;
  --radius-pill: 999px;

  /* Transitions */
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out:    cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --dur-fast:    150ms;
  --dur-mid:     260ms;
  --dur-slow:    420ms;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: var(--line-height);
  letter-spacing: var(--letter-spacing);
  word-spacing: var(--word-spacing);
  color: var(--text-on-ocean);
  min-height: 100vh;
  overflow-x: hidden;

  /* Ocean gradient background */
  background: linear-gradient(160deg, #0047AB 0%, #0077CC 40%, #00B4D8 75%, #48CAE4 100%);
  background-attachment: fixed;
}

/* Subtle wave shimmer overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(255,255,255,0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(0,71,171,0.35) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 50%, rgba(72,202,228,0.10) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

/* Soft dot texture */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
}

/* ── Views ─────────────────────────────────────────────────── */
.view {
  animation: viewIn var(--dur-slow) var(--ease-out) both;
}

.view.hidden { display: none !important; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── App Header / Logo ─────────────────────────────────────── */
.app-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.app-logo-icon {
  width: 52px;
  height: 52px;
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.35);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

h1.app-title {
  font-family: var(--font-display);
  font-size: clamp(36px, 7vw, 56px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--color-white);
}

h1.app-title span { color: var(--color-gold); }

.subtitle {
  font-size: 19px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

/* ── Mascot strip ──────────────────────────────────────────── */
.mascot-strip {
  display: flex;
  gap: var(--space-md);
  align-items: flex-end;
  margin-bottom: var(--space-lg);
}

.mascot-strip svg {
  width: 80px;
  height: auto;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.20));
  animation: mascotFloat 3s ease-in-out infinite;
}

.mascot-strip svg:nth-child(2) { animation-delay: 0.6s; width: 90px; }
.mascot-strip svg:nth-child(3) { animation-delay: 1.2s; }

@keyframes mascotFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

/* ── Decorative floating shapes ────────────────────────────── */
.deco-shapes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.deco-shape {
  position: absolute;
  opacity: 0.14;
  filter: brightness(2);
  animation: decoFloat 6s ease-in-out infinite;
}

.deco-shape:nth-child(1) { top: 8%;  left: 5%;  animation-delay: 0s;   }
.deco-shape:nth-child(2) { top: 20%; right: 6%; animation-delay: 1s;   }
.deco-shape:nth-child(3) { top: 60%; left: 3%;  animation-delay: 2s;   }
.deco-shape:nth-child(4) { top: 75%; right: 4%; animation-delay: 0.5s; }
.deco-shape:nth-child(5) { top: 40%; left: 92%; animation-delay: 1.5s; }

@keyframes decoFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  33%       { transform: translateY(-12px) rotate(5deg); }
  66%       { transform: translateY(6px) rotate(-3deg); }
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  transition:
    transform var(--dur-fast) var(--ease-bounce),
    box-shadow var(--dur-fast) var(--ease-out),
    background var(--dur-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: translateY(2px) !important; }

/* Primary = solid white, navy text */
.btn-primary {
  background: var(--color-white);
  color: var(--color-deep);
  box-shadow: 0 4px 0 0 rgba(0,0,0,0.18), 0 8px 24px rgba(0,0,0,0.15);
}

.btn-primary:hover {
  background: var(--color-gold);
  color: var(--color-deep);
  transform: translateY(-3px);
  box-shadow: 0 7px 0 0 rgba(0,0,0,0.18), 0 14px 32px rgba(0,0,0,0.18);
}

/* Secondary = frosted glass */
.btn-secondary {
  background: var(--glass-bg);
  color: var(--color-white);
  border: 1.5px solid var(--glass-border);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}

.btn-secondary:hover {
  background: var(--glass-bg-strong);
  transform: translateY(-2px);
  box-shadow: 0 4px 18px rgba(0,0,0,0.18);
}

.btn-full { width: 100%; }

/* ── Forms ─────────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: 14px 18px;
  margin-bottom: var(--space-md);
  border: 2px solid rgba(255,255,255,0.30);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: var(--line-height);
  letter-spacing: var(--letter-spacing);
  background: rgba(255,255,255,0.15);
  color: var(--color-white);
  backdrop-filter: blur(8px);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.input::placeholder { color: rgba(255,255,255,0.45); }

.input:focus {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 0 4px rgba(255,209,102,0.25);
}

/* Select options need readable contrast */
.input option {
  background: var(--color-deep);
  color: var(--color-white);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.form-label {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,36,90,0.60);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-md);
  animation: modalBgIn var(--dur-mid) var(--ease-out) both;
}

@keyframes modalBgIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal.hidden { display: none !important; }

.modal-content {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(20px);
  border: 1.5px solid var(--glass-border);
  padding: var(--space-lg);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 420px;
  box-shadow: 0 32px 80px rgba(0,36,90,0.45);
  animation: modalIn var(--dur-slow) var(--ease-bounce) both;
  position: relative;
  overflow: hidden;
}

.modal-content::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-gold), var(--color-light), var(--color-gold));
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.86) translateY(24px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-content h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--color-white);
  margin-bottom: var(--space-lg);
  margin-top: var(--space-xs);
}

.modal-buttons {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.modal-buttons .btn { flex: 1; }

.form-error {
  color: #ffb3b3;
  font-size: 0.875rem;
  text-align: center;
  min-height: 1.2em;
  margin: 0;
}

/* ── Profile Picker ────────────────────────────────────────── */
.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

/* Profile card — frosted glass */
.profile-card {
  position: relative;
  background: var(--glass-bg);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-md);
  text-align: center;
  cursor: pointer;
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(12px);
  transition:
    transform var(--dur-mid) var(--ease-bounce),
    box-shadow var(--dur-mid) var(--ease-out),
    background var(--dur-fast);
  overflow: hidden;
}

.profile-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--color-gold);
  opacity: 0;
  transition: opacity var(--dur-fast);
}

.profile-card:hover::before { opacity: 1; }

.profile-card:hover {
  transform: translateY(-6px) rotate(-1deg);
  background: var(--glass-bg-strong);
  box-shadow: 0 20px 50px rgba(0,36,90,0.30);
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  margin: var(--space-sm) auto var(--space-sm);
  text-transform: uppercase;
  border: 2.5px solid rgba(255,255,255,0.40);
}

/* Avatar colour variants — all inherit white text except gold */
.profile-avatar.bg-sun,         .dashboard-avatar.bg-sun        { background: var(--color-gold);   color: var(--color-deep); }
.profile-avatar.bg-sky,         .dashboard-avatar.bg-sky        { background: rgba(255,255,255,0.25); color: #fff; }
.profile-avatar.bg-green,       .dashboard-avatar.bg-green      { background: rgba(72,202,228,0.50); color: #fff; }
.profile-avatar.bg-tangerine,   .dashboard-avatar.bg-tangerine  { background: rgba(255,255,255,0.18); color: #fff; }

.profile-card-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--color-white);
  margin-bottom: 4px;
}

.profile-card-year {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.profile-card-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  background: rgba(230,57,70,0.15);
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(230,57,70,0.30);
  border-radius: 50%;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--dur-fast), background var(--dur-fast);
}

.profile-card:hover .profile-card-delete { opacity: 1; }

.profile-card-delete:hover {
  background: var(--color-red);
  color: white;
}

/* ── Dashboard ─────────────────────────────────────────────── */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.dashboard-player-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.dashboard-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  border: 2.5px solid rgba(255,255,255,0.40);
  box-shadow: 0 4px 16px rgba(0,0,0,0.20);
}

h1#playerName {
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
  color: var(--color-white);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

#playerYear {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Score banner — glass card */
.score-banner {
  background: var(--glass-bg);
  border: 1.5px solid var(--glass-border);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  box-shadow: var(--glass-shadow);
  position: relative;
  overflow: hidden;
}

.score-banner::after {
  content: '';
  position: absolute;
  right: -20px; top: -20px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  pointer-events: none;
}

.score-banner-icon {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.score-banner-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.score-banner-value {
  font-family: var(--font-number);
  font-size: 52px;
  font-weight: 900;
  line-height: 1;
  color: var(--color-gold);
}

.games-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.games-title::before {
  content: '';
  display: inline-block;
  width: 4px; height: 18px;
  background: var(--color-gold);
  border-radius: 3px;
}

/* Games grid */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-md);
}

.game-card {
  background: var(--glass-bg);
  border: 1.5px solid var(--glass-border);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-xl);
  overflow: hidden;
  cursor: pointer;
  transition:
    transform var(--dur-mid) var(--ease-bounce),
    box-shadow var(--dur-mid) var(--ease-out),
    background var(--dur-fast);
  box-shadow: var(--glass-shadow);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

.game-card:hover {
  transform: translateY(-8px) rotate(0.5deg);
  background: var(--glass-bg-strong);
  box-shadow: 0 24px 56px rgba(0,36,90,0.32);
}

.game-card-header {
  padding: var(--space-md) var(--space-md) var(--space-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  position: relative;
}

.game-card-header-bg {
  position: absolute;
  inset: 0;
  opacity: 0.10;
}

.game-card-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.game-card-icon svg { width: 32px; height: 32px; }

.game-card-meta {
  position: relative;
  z-index: 1;
  flex: 1;
}

.game-card-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--color-white);
  line-height: 1.2;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.game-card-description {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.4;
}

.game-card-body {
  padding: var(--space-sm) var(--space-md) var(--space-md);
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.game-card-score-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.game-card-score {
  font-family: var(--font-number);
  font-size: 30px;
  font-weight: 900;
  color: var(--color-gold);
  line-height: 1;
  margin-bottom: var(--space-sm);
}

.game-card-play {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--color-white);
  color: var(--color-deep);
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur-fast), transform var(--dur-fast) var(--ease-bounce);
  align-self: flex-start;
}

.game-card-play:hover {
  background: var(--color-gold);
  transform: scale(1.05);
}

.game-card-play-arrow {
  font-style: normal;
  display: inline-block;
  transition: transform var(--dur-fast) var(--ease-bounce);
}

.game-card:hover .game-card-play-arrow { transform: translateX(4px); }

/* ── Year badge ────────────────────────────────────────────── */
.year-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.15);
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.20);
}

/* ── Stagger animation ──────────────────────────────────────── */
.profile-card:nth-child(1), .game-card:nth-child(1) { animation-delay: 0.05s; }
.profile-card:nth-child(2), .game-card:nth-child(2) { animation-delay: 0.10s; }
.profile-card:nth-child(3), .game-card:nth-child(3) { animation-delay: 0.15s; }
.profile-card:nth-child(4), .game-card:nth-child(4) { animation-delay: 0.20s; }
.profile-card:nth-child(5), .game-card:nth-child(5) { animation-delay: 0.25s; }
.profile-card:nth-child(6), .game-card:nth-child(6) { animation-delay: 0.30s; }

.profile-card, .game-card {
  animation: cardIn var(--dur-slow) var(--ease-bounce) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.93); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
  color: var(--text-muted);
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-md);
  opacity: 0.5;
}

.empty-state p {
  font-size: 18px;
  font-weight: 600;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .container { padding: var(--space-md) var(--space-sm); }

  h1.app-title { font-size: 36px; }

  .profiles-grid { grid-template-columns: repeat(2, 1fr); }

  .dashboard-header {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .games-grid { grid-template-columns: 1fr; }

  .score-banner-value { font-size: 40px; }

  .mascot-strip { display: none; }

  .modal-content { padding: var(--space-md); }
}

@media (max-width: 380px) {
  .profiles-grid { grid-template-columns: 1fr; }
}
