/* =========================================================
   Kairu's Timetables — style.css  (v0.2 polished)
   Kerwin Springer brand: Poppins + Fredoka, navy + gold,
   frosted-glass shell, restrained visual language.
   ========================================================= */

:root {
  --navy:        #2B4C7E;
  --navy-deep:   #1F3A63;
  --gold:        #F5A623;
  --gold-warm:   #FFC65C;
  --sky:         #6B8AAD;
  --sky-light:   #E8F0FE;
  --paper:       #F7FAFF;
  --ink:         #14213D;
  --muted:       #5C6B85;

  --zone-a:      #E84545;
  --zone-b:      #F6A23D;
  --zone-c:      #2DD4A4;
  --zone-d:      #4F8DF7;

  --radius-lg:   18px;
  --radius-md:   12px;
  --radius-sm:   8px;

  --shadow-soft: 0 6px 20px rgba(20, 33, 61, 0.08);
  --shadow-pop:  0 14px 36px rgba(20, 33, 61, 0.18);

  --ui-font:     "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display:     "Fredoka", "Poppins", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--ui-font);
  color: var(--ink);
  background:
    radial-gradient(1400px 700px at 12% -10%, #C8DDFF 0%, transparent 60%),
    radial-gradient(1100px 600px at 110% 110%, #FFE2B0 0%, transparent 55%),
    var(--sky-light);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { overscroll-behavior-y: none; }

/* ---------- Page layout ---------- */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.page-header {
  text-align: center;
  margin-bottom: 22px;
}

.brandline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy);
  text-decoration: none;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
a.brandline:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(43,76,126,0.18);
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.18);
}

.page-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(36px, 6vw, 56px);
  margin: 14px 0 6px;
  color: var(--navy-deep);
  letter-spacing: -0.02em;
}

.page-tagline {
  margin: 0 auto;
  max-width: 560px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

/* ---------- Game shell ---------- */

.game-shell {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 22px;
  display: grid;
  gap: 16px;
}

@media (max-width: 600px) {
  .game-shell { padding: 14px; gap: 12px; }
  .page { padding: 18px 12px 36px; }
}

/* ---------- HUD strip ---------- */

.hud-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.hud-side {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-right { justify-content: flex-end; }

.tier-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--navy-deep);
  background: rgba(245, 166, 35, 0.12);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(245, 166, 35, 0.22);
}

.level-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 22px 10px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(31, 58, 99, 0.30);
  position: relative;
}

.level-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  opacity: 0.7;
}

.level-num {
  font-family: var(--display);
  font-weight: 700;
  font-size: 32px;
  line-height: 1.05;
  color: var(--gold-warm);
  text-shadow: 0 1px 0 rgba(0,0,0,0.25);
}

.level-chip.pulse {
  animation: levelPulse 0.45s ease-out;
}
@keyframes levelPulse {
  0%   { transform: scale(1.0); box-shadow: 0 6px 16px rgba(31,58,99,0.30), 0 0 0 0 rgba(245,166,35,0.6); }
  40%  { transform: scale(1.06); box-shadow: 0 6px 16px rgba(31,58,99,0.30), 0 0 0 8px rgba(245,166,35,0.0); }
  100% { transform: scale(1.0);  box-shadow: 0 6px 16px rgba(31,58,99,0.30), 0 0 0 0 rgba(245,166,35,0.0); }
}

.streak-flame {
  font-size: 14px;
  font-weight: 700;
  color: #B8541E;
  background: rgba(245, 166, 35, 0.14);
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(245, 166, 35, 0.30);
  font-variant-numeric: tabular-nums;
}

.streak-flame.hot {
  color: #fff;
  background: linear-gradient(180deg, #F5A623 0%, #E07B00 100%);
  border-color: rgba(0,0,0,0.05);
  box-shadow: 0 4px 10px rgba(245, 166, 35, 0.45);
}

.best-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(43, 76, 126, 0.08);
  border: 1px solid rgba(43, 76, 126, 0.14);
  border-radius: 999px;
  font-family: var(--ui-font);
  font-size: 13px;
  color: var(--navy-deep);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
}
.best-chip:hover {
  background: rgba(245, 166, 35, 0.18);
  border-color: rgba(245, 166, 35, 0.35);
  box-shadow: 0 4px 12px rgba(245, 166, 35, 0.25);
}
.best-chip:active { transform: translateY(1px); }
.best-chip:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.best-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.best-chip b {
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
  color: var(--navy-deep);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 520px) {
  .tier-name  { font-size: 11px; padding: 6px 10px; letter-spacing: 0.08em; }
  .level-chip { padding: 6px 16px 8px; }
  .level-num  { font-size: 26px; }
  .best-chip  { padding: 4px 10px; font-size: 12px; }
  .best-chip b { font-size: 14px; }
}

/* ---------- Canvas ---------- */

.game-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: linear-gradient(180deg, #BEE7FF 0%, #7FCBFF 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.5),
    0 8px 22px rgba(20, 33, 61, 0.12);
  cursor: pointer;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Flight controls (Up / Down) ---------- */

.flight-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.flight-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--ui-font);
  border-radius: var(--radius-md);
  padding: 16px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  box-shadow: 0 4px 0 rgba(0,0,0,0.22), var(--shadow-soft);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.flight-btn:hover  { filter: brightness(1.08); }
.flight-btn:active,
.flight-btn.pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.22), var(--shadow-soft);
}

.flight-arrow {
  font-size: 20px;
  line-height: 1;
  color: var(--gold-warm);
  text-shadow: 0 1px 0 rgba(0,0,0,0.25);
}

.flight-label {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.flight-key {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.7;
  font-weight: 600;
}

@media (max-width: 420px) {
  .flight-btn { padding: 14px 10px; gap: 10px; }
  .flight-label { font-size: 18px; }
  .flight-key   { display: none; }
}

/* ---------- Help text ---------- */

.game-help {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
  background: rgba(43, 76, 126, 0.04);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.game-help b { color: var(--navy-deep); }

kbd {
  display: inline-block;
  font-family: var(--ui-font);
  font-size: 11.5px;
  font-weight: 700;
  padding: 1.5px 6.5px;
  margin: 0 1px;
  border-radius: 6px;
  background: #fff;
  color: var(--navy-deep);
  border: 1px solid rgba(43, 76, 126, 0.18);
  box-shadow: 0 1px 0 rgba(43, 76, 126, 0.12);
}

/* ---------- Footer ---------- */

.page-footer {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.page-footer .dot { opacity: 0.5; }

.page-footer .link {
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--navy);
  font-family: var(--ui-font);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.04em;
}
.page-footer .link:hover { background: rgba(43, 76, 126, 0.06); color: var(--navy-deep); }

/* ---------- Name-entry overlay (new best) ---------- */

.name-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 33, 61, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: nameFadeIn 0.35s ease;
}

.name-overlay[hidden] { display: none; }

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

.name-card {
  background: linear-gradient(160deg, #FFE3B0 0%, #F5A623 65%, #C77E0E 100%);
  padding: 24px 26px 22px;
  border-radius: 18px;
  text-align: center;
  width: min(300px, 86%);
  box-shadow: 0 22px 44px rgba(20, 33, 61, 0.45),
              inset 0 1px 0 rgba(255, 255, 255, 0.5);
  animation: nameCardIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes nameCardIn {
  from { transform: scale(0.7) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.name-icon {
  font-size: 36px;
  line-height: 1;
  margin-bottom: 4px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.18));
}

.name-label {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  color: var(--navy-deep);
  letter-spacing: 0.05em;
}

.name-score {
  font-family: var(--display);
  font-weight: 800;
  font-size: 56px;
  color: var(--navy-deep);
  line-height: 1;
  margin: 4px 0 14px;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.35);
}

#nameField {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid rgba(31, 58, 99, 0.25);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 10px;
  font-family: var(--ui-font);
  font-size: 16px;
  font-weight: 600;
  color: var(--navy-deep);
  text-align: center;
  outline: none;
  transition: border-color 0.15s ease;
}

#nameField:focus {
  border-color: var(--navy-deep);
  background: #fff;
}

.name-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.name-btn {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-family: var(--ui-font);
  font-weight: 700;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--navy-deep);
  transition: transform 0.08s ease, filter 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.name-btn:hover  { filter: brightness(1.06); }
.name-btn:active { transform: translateY(1px); }

.name-btn.primary {
  background: var(--navy-deep);
  color: var(--gold-warm);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
}

/* ---------- Trophy modal (BEST chip click) ---------- */

.best-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.best-modal[hidden] { display: none; }

.best-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 33, 61, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: nameFadeIn 0.25s ease;
}

.trophy-card {
  position: relative;
  width: min(420px, 92vw);
  background:
    radial-gradient(circle at 30% 0%, rgba(255, 255, 255, 0.55) 0%, transparent 50%),
    linear-gradient(160deg, #FFE3B0 0%, #F5A623 55%, #B86E10 100%);
  border-radius: 24px;
  padding: 38px 32px 26px;
  text-align: center;
  color: var(--navy-deep);
  box-shadow:
    0 30px 60px rgba(20, 33, 61, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  animation: trophyIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  isolation: isolate;
}

@keyframes trophyIn {
  0%   { transform: scale(0.55) rotate(-8deg); opacity: 0; }
  100% { transform: scale(1)    rotate(0);    opacity: 1; }
}

.trophy-shine {
  position: absolute;
  top: -50%;
  left: -30%;
  width: 60%;
  height: 200%;
  background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.40) 50%, transparent 100%);
  transform: rotate(20deg);
  pointer-events: none;
  z-index: 0;
  animation: trophyShine 4s ease-in-out infinite;
}

@keyframes trophyShine {
  0%, 100% { transform: rotate(20deg) translateX(-30%); opacity: 0; }
  40%      { opacity: 0.8; }
  60%      { opacity: 0.8; }
  100%     { transform: rotate(20deg) translateX(220%); opacity: 0; }
}

.trophy-card > * { position: relative; z-index: 1; }

.trophy-close {
  position: absolute;
  top: 12px; right: 14px;
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  border: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  font-weight: 600;
  z-index: 2;
  transition: background 0.15s ease;
}

.trophy-close:hover { background: rgba(0, 0, 0, 0.32); }

.trophy-icon {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 6px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.22));
}

.trophy-label {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(31, 58, 99, 0.65);
}

.trophy-number {
  font-family: var(--display);
  font-size: clamp(72px, 18vw, 96px);
  font-weight: 800;
  color: var(--navy-deep);
  line-height: 1;
  margin: 6px 0 10px;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.45);
}

.trophy-name {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 600;
  color: var(--navy-deep);
  margin-bottom: 4px;
}

.trophy-meta { margin-top: 10px; }

.trophy-tier {
  display: inline-block;
  background: rgba(255, 255, 255, 0.45);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy-deep);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.trophy-date {
  font-size: 12px;
  color: rgba(31, 58, 99, 0.65);
  margin-top: 10px;
  font-weight: 500;
}

.trophy-footer {
  margin-top: 22px;
  font-size: 10px;
  color: rgba(31, 58, 99, 0.5);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  .level-chip.pulse {
    transition: none !important;
    animation: none !important;
  }
}


/* ===== Practice mode (v0.3) ===== */
.mode-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 2px;
  flex-wrap: wrap;
}
.mode-btn {
  font-family: var(--display, 'Fredoka'), 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 13.5px;
  border: 1.5px solid rgba(31, 58, 99, 0.18);
  background: rgba(255, 255, 255, 0.75);
  color: #1F3A63;
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  transition: all .16s ease;
}
.mode-btn:hover { border-color: rgba(31, 58, 99, 0.4); transform: translateY(-1px); }
.mode-btn.active {
  background: #1F3A63;
  color: #FFE08A;
  border-color: #1F3A63;
  box-shadow: 0 6px 16px rgba(31, 58, 99, 0.28);
}
.mode-note {
  font-size: 11.5px;
  font-weight: 600;
  color: rgba(31, 58, 99, 0.55);
  margin-left: 2px;
}
.feathers-chip {
  font-family: var(--display, 'Fredoka'), 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #1F3A63;
  background: rgba(43, 182, 217, 0.14);
  border: 1px solid rgba(43, 182, 217, 0.32);
  padding: 8px 13px;
  border-radius: 999px;
  transition: transform .15s ease;
}
.feathers-chip.low { background: rgba(232, 69, 69, 0.12); border-color: rgba(232, 69, 69, 0.4); color: #B23030; }
.feathers-chip.losing { animation: featherPulse .55s ease; }
@keyframes featherPulse { 0%,100% { transform: scale(1); } 40% { transform: scale(1.18); } }

.practice-card { max-width: 420px; }
.practice-sub {
  font-size: 13.5px;
  color: rgba(31, 58, 99, 0.75);
  line-height: 1.6;
  margin: 6px 0 14px;
}
.table-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.table-chip {
  font-family: var(--display, 'Fredoka'), 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 15px;
  padding: 10px 0;
  border-radius: 12px;
  border: 2px solid rgba(31, 58, 99, 0.16);
  background: #fff;
  color: #1F3A63;
  cursor: pointer;
  transition: all .14s ease;
}
.table-chip:hover { border-color: rgba(31, 58, 99, 0.45); transform: translateY(-1px); }
.table-chip.sel {
  background: #1F3A63;
  color: #FFE08A;
  border-color: #1F3A63;
  box-shadow: 0 4px 12px rgba(31, 58, 99, 0.3);
}
.practice-start {
  width: 100%;
  font-family: var(--display, 'Fredoka'), 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 16px;
  background: #F5A623;
  color: #1a1206;
  border: 0;
  border-radius: 13px;
  padding: 13px 18px;
  cursor: pointer;
  transition: filter .15s, transform .15s;
}
.practice-start:hover { filter: brightness(1.06); transform: translateY(-1px); }
.trophy-card.shake { animation: cardShake .4s ease; }
@keyframes cardShake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-7px)} 50%{transform:translateX(7px)} 75%{transform:translateX(-4px)} }
@media (max-width: 560px) {
  .mode-note { width: 100%; }
}

/* mode-switch confirm modal */
.switch-card { max-width: 380px; }
.switch-actions { display: flex; flex-direction: column; gap: 9px; }
.switch-cancel {
  width: 100%;
  font-family: var(--display, 'Fredoka'), 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 14.5px;
  background: #fff;
  color: #1F3A63;
  border: 1.5px solid rgba(31, 58, 99, 0.22);
  border-radius: 13px;
  padding: 11px 18px;
  cursor: pointer;
  transition: all .15s ease;
}
.switch-cancel:hover { border-color: rgba(31, 58, 99, 0.5); transform: translateY(-1px); }
