@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Nunito:wght@400;700;900&display=swap');

:root {
  --c1: #FF6B6B;
  --c2: #4ECDC4;
  --c3: #45B7D1;
  --c4: #96CEB4;
  --c5: #FFEAA7;
  --c6: #DDA0DD;
  --bg: #1a1a2e;
  --dark: #0f0f23;
  --text: #f0f0f0;
}

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

body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  min-height: 100vh;
  color: var(--text);
}

/* ── Language bar ── */
.lang-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(0,0,0,0.35);
  flex-wrap: wrap;
  width: 100%;
}
.lang-btn {
  background: transparent;
  border: 2px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.55);
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  transition: all 0.2s;
}
.lang-btn:hover { border-color: var(--c2); color: var(--c2); }
.lang-btn.active { background: var(--c2); border-color: var(--c2); color: var(--dark); }

/* ── Lobby header ── */
.site-header { text-align: center; padding: 36px 20px 16px; }
.site-title {
  font-family: 'Press Start 2P', cursive;
  font-size: clamp(1rem, 4vw, 2.2rem);
  background: linear-gradient(90deg, #FF6B6B, #FFEAA7, #4ECDC4, #96CEB4, #DDA0DD, #FF6B6B);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 400% 100%;
  animation: rainbow 5s linear infinite;
  line-height: 1.5;
  margin-bottom: 12px;
}
.site-subtitle { font-size: 1.05rem; color: rgba(255,255,255,0.65); font-weight: 700; }

@keyframes rainbow { 0%{background-position:0%} 100%{background-position:400%} }

/* ── Game grid ── */
.games-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  max-width: 1100px;
  margin: 36px auto 20px;
  padding: 0 24px;
}
@media (max-width: 700px) {
  .games-grid { grid-template-columns: 1fr; }
}
.game-tile {
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}
.game-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.3s;
  border-radius: 18px;
}
.game-tile.snake::before        { background: linear-gradient(135deg,rgba(78,205,196,.22),rgba(150,206,180,.22)); }
.game-tile.pong::before         { background: linear-gradient(135deg,rgba(255,107,107,.22),rgba(255,234,167,.22)); }
.game-tile.connect-dots::before { background: linear-gradient(135deg,rgba(221,160,221,.22),rgba(69,183,209,.22)); }
.game-tile.volleyball::before   { background: linear-gradient(135deg,rgba(255,142,83,.22), rgba(255,234,167,.22)); }
.game-tile.shapecatcher::before { background: linear-gradient(135deg,rgba(69,183,209,.22), rgba(78,205,196,.22));  }
.game-tile.risingcave::before   { background: linear-gradient(135deg,rgba(180,100,220,.22),rgba(219,112,147,.22)); }
.game-tile.symbolfolge::before  { background: linear-gradient(135deg,rgba(139,92,246,.22), rgba(167,139,250,.22)); }
.game-tile.fourier::before      { background: linear-gradient(135deg,rgba(14,165,233,.22),  rgba(6,182,212,.22));   }
.game-tile.pythagoras::before   { background: linear-gradient(135deg,rgba(245,158,11,.22),  rgba(251,191,36,.22));  }
.game-tile.unlockgame::before   { background: linear-gradient(135deg,rgba(16,185,129,.22),  rgba(52,211,153,.22));  }
.game-tile.lockpicking::before  { background: linear-gradient(135deg,rgba(234,88,12,.22),   rgba(249,115,22,.22));  }
.game-tile:hover { transform: translateY(-7px) scale(1.02); border-color: rgba(255,255,255,.4); box-shadow: 0 20px 40px rgba(0,0,0,.45); }
.game-tile:hover::before { opacity: 1; }

.tile-icon { font-size: 3.8rem; display: block; margin-bottom: 14px; animation: bob 2.5s ease-in-out infinite; }
.game-tile:hover .tile-icon { animation: pop .4s ease; }

@keyframes bob  { 0%,100%{transform:translateY(0)}  50%{transform:translateY(-8px)} }
@keyframes pop  { 0%{transform:scale(1)} 50%{transform:scale(1.35) rotate(8deg)} 100%{transform:scale(1)} }

.tile-title { font-family: 'Press Start 2P', cursive; font-size: 1rem; margin-bottom: 10px; }
.game-tile.snake        .tile-title { color: var(--c2); }
.game-tile.pong         .tile-title { color: var(--c1); }
.game-tile.connect-dots .tile-title { color: var(--c6); }
.game-tile.volleyball   .tile-title { color: #FF8E53; }
.game-tile.shapecatcher .tile-title { color: #45B7D1; }
.game-tile.risingcave   .tile-title { color: #C970E0; }
.game-tile.symbolfolge  .tile-title { color: #A78BFA; }
.game-tile.fourier      .tile-title { color: #38BDF8; }
.game-tile.pythagoras   .tile-title { color: #FBBF24; }
.game-tile.unlockgame   .tile-title { color: #34D399; }
.game-tile.lockpicking  .tile-title { color: #F97316; }

.tile-desc { font-size: 0.92rem; color: rgba(255,255,255,.6); margin-bottom: 20px; line-height: 1.55; }

.play-btn {
  display: inline-block;
  padding: 9px 26px;
  border-radius: 30px;
  font-family: 'Press Start 2P', cursive;
  font-size: 0.65rem;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.game-tile.snake        .play-btn { background: linear-gradient(90deg, var(--c2), var(--c4)); color: var(--dark); }
.game-tile.pong         .play-btn { background: linear-gradient(90deg, var(--c1), var(--c5)); color: var(--dark); }
.game-tile.connect-dots .play-btn { background: linear-gradient(90deg, var(--c6), var(--c3)); color: var(--dark); }
.game-tile.volleyball   .play-btn { background: linear-gradient(90deg, #FF8E53, var(--c5));  color: var(--dark); }
.game-tile.shapecatcher .play-btn { background: linear-gradient(90deg, #45B7D1, var(--c2)); color: var(--dark); }
.game-tile.risingcave    .play-btn { background: linear-gradient(90deg, #C970E0, #DB7093);  color: #fff; }
.game-tile.symbolfolge  .play-btn { background: linear-gradient(90deg, #8B5CF6, #A78BFA);  color: #fff; }
.game-tile.fourier      .play-btn { background: linear-gradient(90deg, #0EA5E9, #06B6D4);  color: #fff; }
.game-tile.pythagoras   .play-btn { background: linear-gradient(90deg, #F59E0B, #FBBF24);  color: var(--dark); }
.game-tile.unlockgame   .play-btn { background: linear-gradient(90deg, #10B981, #34D399);  color: var(--dark); }
.game-tile.lockpicking  .play-btn { background: linear-gradient(90deg, #EA580C, #F97316);  color: #fff; }

/* ── Rising Cave touch controls ── */
.rc-controls {
  display: none;
  gap: 16px;
  padding: 10px 16px 16px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}
.rc-btn {
  flex: 1;
  height: 72px;
  background: rgba(255,255,255,.07);
  border: 2px solid rgba(255,255,255,.18);
  border-radius: 14px;
  color: rgba(255,255,255,.85);
  font-size: 1.8rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s, border-color .1s;
}
.rc-btn:active { background: rgba(201,112,224,.3); border-color: #C970E0; }
@media (hover: none), (pointer: coarse) {
  .rc-controls { display: flex; }
}
.play-btn:hover { transform: scale(1.07); box-shadow: 0 4px 16px rgba(0,0,0,.35); }

/* ── Game page layout ── */
body.game-page { display: flex; flex-direction: column; align-items: center; }

.game-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: rgba(0,0,0,0.35);
  flex-wrap: wrap;
  gap: 10px;
}
.back-btn {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.6rem;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  padding: 8px 14px;
  border: 2px solid rgba(255,255,255,.25);
  border-radius: 20px;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
}
.back-btn:hover { color: #fff; border-color: #fff; }

.game-title-bar {
  font-family: 'Press Start 2P', cursive;
  font-size: clamp(0.75rem, 2vw, 1.1rem);
}

.score-bar { display: flex; gap: 20px; font-family: 'Press Start 2P', cursive; }
.score-item { text-align: center; }
.score-label { color: rgba(255,255,255,.45); margin-bottom: 3px; font-size: 0.5rem; }
.score-value { color: var(--c5); font-size: 0.85rem; }

.game-controls { display: flex; justify-content: center; gap: 10px; padding: 8px 0; width: 100%; }

.canvas-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; }
canvas { border-radius: 12px; box-shadow: 0 0 50px rgba(0,0,0,.6); max-width: 100%; max-height: 70vh; touch-action: none; }

/* ── Show-on-touch helper (opposite of hide-on-touch) ── */
.show-on-touch { display: none; }

/* ── Snake: canvas + D-pad side-by-side ── */
.snake-game-area {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;          /* D-pad must never wrap below */
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;              /* allow flex shrinking */
  width: 100%;
  gap: 12px;
  padding: 8px 16px;
}
.snake-game-area .canvas-wrap {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 4px;
}

/* ── D-pad (Snake touch controls) ── */
.dpad {
  display: none;
  grid-template-areas: ". up ." "left . right" ". down .";
  grid-template-columns: repeat(3, 90px);
  grid-template-rows: repeat(3, 90px);
  gap: 8px;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
}
.dpad-up    { grid-area: up; }
.dpad-left  { grid-area: left; }
.dpad-right { grid-area: right; }
.dpad-down  { grid-area: down; }
.dpad-btn {
  width: 100%; height: 100%;
  background: rgba(255,255,255,.08);
  border: 2px solid rgba(255,255,255,.18);
  border-radius: 16px;
  color: rgba(255,255,255,.85);
  font-size: 2rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s, border-color .1s;
}
.dpad-btn:active { background: rgba(78,205,196,.35); border-color: var(--c2); }

/* ── Touch-device overrides (coarse pointer OR no-hover — catches all tablets) ── */
@media (hover: none), (pointer: coarse) {
  .dpad { display: grid; }
  .show-on-touch { display: flex; }

  /* No scrolling on game pages */
  body.game-page {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  /* Prevent accidental text-selection on interactive chrome */
  body.game-page .game-header,
  body.game-page .game-controls,
  body.game-page .lang-bar,
  body.game-page .rules-card,
  body.game-page .vb-positions,
  body.game-page .rc-controls { user-select: none; -webkit-user-select: none; }

  /* Canvas-wrap: must shrink so canvas doesn't overflow */
  body.game-page .canvas-wrap {
    min-height: 0;
    min-width: 0;
    padding: 6px;
  }

  /* Canvas fills available space without overflowing */
  body.game-page canvas {
    max-height: 100%;
    max-width: 100%;
  }

  /* Snake canvas: leave 310px for D-pad + gap + padding */
  .snake-game-area canvas {
    max-width: calc(100vw - 310px);
    max-height: 80vh;
  }
  .snake-game-area .canvas-wrap { padding: 4px; }

  /* Larger tap targets */
  .back-btn { padding: 12px 16px; font-size: 0.62rem; min-height: 44px; }
  .game-controls { padding: 10px 0; gap: 12px; }

  /* Volleyball position buttons */
  .vb-btn { height: 80px; font-size: 1.3rem; }
}

/* ── Overlay ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(5px);
}
.overlay.hidden { display: none; }
.overlay-box {
  background: linear-gradient(160deg, #1c1c35 0%, #141428 100%);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 24px;
  padding: 32px 28px 26px;
  text-align: center;
  max-width: 460px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
.overlay-title {
  font-family: 'Press Start 2P', cursive;
  font-size: 1.1rem;
  margin-bottom: 16px;
  position: relative;
  padding-bottom: 14px;
}
.overlay-title::after {
  content: '';
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 56px; height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--c1), var(--c5), var(--c2));
}
.overlay-score { font-family: 'Press Start 2P', cursive; font-size: 2rem; color: var(--c5); margin: 14px 0 6px; }
.overlay-sub {
  color: rgba(255,255,255,.45);
  font-size: 0.88rem;
  margin-bottom: 20px;
}
.btn-primary {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.7rem;
  padding: 13px 30px;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  background: linear-gradient(90deg, #FF6B6B, #FFEAA7, #4ECDC4);
  color: var(--dark);
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn-primary:hover { transform: scale(1.06); box-shadow: 0 4px 20px rgba(255,107,107,.45); }
.controls-hint { margin-top: 18px; font-size: 0.72rem; color: rgba(255,255,255,.35); line-height: 2; }

/* ── Footer ── */
footer { text-align: center; padding: 18px; color: rgba(255,255,255,.2); font-size: 0.8rem; }
footer a.footer-link { color: rgba(255,255,255,.28); text-decoration: none; margin: 0 8px; transition: color .2s; }
footer a.footer-link:hover { color: rgba(255,255,255,.65); }
.visitor-counter { color: rgba(255,255,255,.28); font-size: 0.82rem; }
#visitor-count { color: rgba(255,255,255,.5); font-weight: 800; }

/* ── Impressum page ── */
.impr-h1 {
  font-family: 'Press Start 2P', cursive;
  font-size: clamp(1rem, 3vw, 1.6rem);
  margin-bottom: 36px;
  background: linear-gradient(90deg, var(--c2), var(--c6));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.impr-section { margin-bottom: 32px; }
.impr-h2 {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.6rem;
  color: var(--c2);
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(78,205,196,.2);
}
.impr-section p {
  color: rgba(255,255,255,.65);
  font-size: 0.92rem;
  line-height: 1.8;
}
.impr-link { color: var(--c2); text-decoration: none; transition: color .2s; }
.impr-link:hover { color: var(--c5); }
.impr-footer { margin-top: 48px; color: rgba(255,255,255,.2); font-size: 0.8rem; text-align: center; }

/* ── Overlay action buttons ── */
.overlay-btns { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.btn-lobby {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.62rem;
  padding: 13px 22px;
  border: 2px solid rgba(255,255,255,.28);
  border-radius: 30px;
  color: rgba(255,255,255,.68);
  background: transparent;
  cursor: pointer;
  transition: border-color .2s, color .2s;
  display: inline-block;
  line-height: 1;
}
.btn-lobby:hover { border-color: #fff; color: #fff; }

/* ── Volleyball touch position buttons ── */
.vb-positions {
  display: none;
  gap: 8px;
  padding: 8px 16px 16px;
  width: 100%;
}
.vb-btn {
  flex: 1;
  height: 76px;
  background: color-mix(in srgb, var(--vb-clr) 18%, transparent);
  border: 2px solid color-mix(in srgb, var(--vb-clr) 50%, transparent);
  border-radius: 14px;
  color: var(--vb-clr);
  font-family: 'Press Start 2P', cursive;
  font-size: 1.2rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: filter .1s;
}
.vb-btn:active { filter: brightness(1.6); }

@media (hover: none), (pointer: coarse) {
  .vb-positions { display: flex; }
}

/* ── Hide on touch devices ── */
@media (hover: none), (pointer: coarse) {
  .hide-on-touch { display: none !important; }
}

/* ── Pong rules card ── */
.rules-card { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 6px 16px 14px; max-width: 640px; width: 100%; }
.rule-item {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 20px; padding: 6px 14px;
  font-size: 0.78rem; color: rgba(255,255,255,.65); font-weight: 700; white-space: nowrap;
}
.rule-icon { font-size: 0.95rem; }

/* ── Symbolfolge game ── */
.sym-game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 12px 16px 20px;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  min-height: 0;
}
.sym-lives { font-size: 1.3rem; letter-spacing: 4px; }
.sym-qlabel {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.58rem;
  color: var(--c2);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.sym-seq {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  max-width: 100%;
}
.sym-slot {
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 8px 12px;
  min-width: 52px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  line-height: 1.3;
  text-align: center;
}
.sym-slot.sym-q {
  border-color: var(--c2);
  color: var(--c2);
  font-family: 'Press Start 2P', cursive;
  font-size: 1.5rem;
  min-width: 58px;
  box-shadow: 0 0 14px rgba(78,205,196,0.22);
}
.sym-arrow { color: rgba(255,255,255,0.28); font-size: 1.3rem; padding: 0 2px; }
.sym-choices { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.sym-btn {
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(255,255,255,0.18);
  border-radius: 16px;
  padding: 14px 22px;
  font-size: 1.45rem;
  color: #fff;
  cursor: pointer;
  min-width: 105px;
  min-height: 76px;
  line-height: 1.3;
  transition: background .12s, border-color .12s, transform .1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.sym-btn:hover  { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.42); }
.sym-btn:active { transform: scale(0.95); }
.sym-btn.sym-correct { background: rgba(78,205,196,0.28);  border-color: var(--c2); box-shadow: 0 0 16px rgba(78,205,196,0.3); }
.sym-btn.sym-wrong   { background: rgba(255,107,107,0.25); border-color: var(--c1); }
.sym-btn:disabled    { opacity: 0.55; cursor: default; }
.sym-key-hint {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.48rem;
  color: rgba(255,255,255,0.2);
  letter-spacing: 2px;
}
.sym-lvlup {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Press Start 2P', cursive;
  font-size: 1.4rem;
  color: #FFEAA7;
  background: rgba(8,8,20,0.88);
  padding: 16px 28px;
  border-radius: 14px;
  border: 2px solid rgba(255,234,167,0.3);
  z-index: 60;
  pointer-events: none;
  transition: opacity 0.3s;
}
@media (pointer: coarse) {
  .sym-btn { min-height: 88px; min-width: 115px; font-size: 1.6rem; padding: 16px 20px; }
  .sym-slot { min-height: 58px; min-width: 58px; font-size: 1.45rem; }
  .sym-game-area { gap: 18px; padding: 8px 12px 16px; }
}

/* ── Fourier game ── */
.fourier-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 10px;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  min-height: 0;
  overflow: hidden;
}
.fourier-top-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}
.fourier-btn-group { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.fw-btn {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.48rem;
  padding: 7px 11px;
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: all .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.fw-btn:hover  { border-color: rgba(255,255,255,0.5); color: #fff; }
.fw-btn.active { background: rgba(14,165,233,0.25); border-color: #38BDF8; color: #38BDF8; }

.fourier-canvas-box { width: 100%; flex-shrink: 0; }
.fourier-canvas-box canvas { width:100%; height:auto; border-radius:10px; box-shadow:0 0 30px rgba(0,0,0,.6); touch-action:none; }

.fourier-score-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.fourier-bar-track {
  flex: 1;
  min-width: 80px;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
}
.fourier-bar-fill { height: 100%; width: 0; border-radius: 4px; transition: width .2s, background .3s; }
.fourier-pct { font-family:'Press Start 2P',cursive; font-size:0.6rem; color:#FFEAA7; min-width:36px; }
.fw-act-btn {
  font-family:'Press Start 2P',cursive; font-size:0.48rem;
  padding:7px 12px; border:2px solid rgba(255,255,255,0.22); border-radius:8px;
  background:rgba(255,255,255,0.06); color:rgba(255,255,255,0.7); cursor:pointer;
  transition:all .15s; touch-action:manipulation; white-space:nowrap;
}
.fw-act-btn:hover { border-color:rgba(255,255,255,0.5); color:#fff; }
.fw-next-btn {
  font-family:'Press Start 2P',cursive; font-size:0.48rem;
  padding:7px 14px; border:none; border-radius:8px;
  background:linear-gradient(90deg,#0EA5E9,#4ECDC4); color:#fff;
  cursor:pointer; transition:transform .15s; white-space:nowrap;
}
.fw-next-btn:hover { transform:scale(1.05); }

/* Sliders */
.fourier-sliders {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
.fourier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}
.fourier-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
}
.fourier-lbl {
  font-family:'Press Start 2P',cursive; font-size:0.48rem;
  color:rgba(255,255,255,0.55); min-width:22px; text-align:right;
  flex-shrink:0;
}
.fourier-range {
  flex: 1;
  height: 5px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.18);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  min-width: 0;
}
.fourier-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #38BDF8;
  cursor: pointer;
  box-shadow: 0 0 5px rgba(56,189,248,.5);
}
.fourier-range::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #38BDF8;
  cursor: pointer;
  border: none;
}
.fourier-range:disabled { opacity: 0.35; cursor: default; }
.fourier-val {
  font-family:'Press Start 2P',cursive; font-size:0.45rem;
  color:#38BDF8; min-width:34px; text-align:right; flex-shrink:0;
}
/* Touch: bigger thumbs */
@media (pointer: coarse) {
  .fourier-range { height: 7px; }
  .fourier-range::-webkit-slider-thumb { width:22px; height:22px; }
  .fourier-row { padding: 5px 2px; }
  .fw-btn { padding: 9px 14px; font-size: 0.52rem; min-height: 38px; }
  .fw-act-btn { padding: 9px 14px; min-height: 38px; }
}

/* ── Pythagoras game ── */
.pyth-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 14px;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  min-height: 0;
}
.pyth-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.pyth-lvl-lbl {
  font-family:'Press Start 2P',cursive; font-size:0.58rem; color:#FBBF24;
}
.pyth-dots { display:flex; gap:6px; }
.pyth-dot  { font-size:0.9rem; color:rgba(255,255,255,0.25); }
.pyth-dot.done { color:#FBBF24; }
.pyth-dot.cur  { color:#F59E0B; text-shadow:0 0 8px rgba(245,158,11,0.7); }
.pyth-qnum { font-family:'Press Start 2P',cursive; font-size:0.55rem; color:rgba(255,255,255,0.45); }

.pyth-timer { display:flex; align-items:center; gap:8px; width:100%; }
.pyth-ttrack { flex:1; height:8px; background:rgba(255,255,255,0.12); border-radius:4px; overflow:hidden; }
.pyth-tbar   { height:100%; width:100%; background:#4ECDC4; border-radius:4px; transition:width 1s linear, background .3s; }
.pyth-tval   { font-family:'Press Start 2P',cursive; font-size:0.6rem; color:#FFEAA7; min-width:30px; text-align:right; }

.pyth-canvas-box { width:100%; flex-shrink:0; }
.pyth-canvas-box canvas { width:100%; height:auto; border-radius:10px; box-shadow:0 0 30px rgba(0,0,0,.6); }

.pyth-formula {
  font-family:'Press Start 2P',cursive; font-size:0.58rem;
  color:rgba(255,255,255,0.28); letter-spacing:1px;
}

.pyth-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
}
.pyth-find-lbl {
  font-family:'Press Start 2P',cursive; font-size:0.58rem;
  color:#FF6B6B; white-space:nowrap; flex-shrink:0;
}
.pyth-input {
  flex: 1;
  background-color: #0c1220;
  border: 2px solid #F59E0B;
  border-radius: 10px;
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 10px 14px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  caret-color: #FBBF24;
  transition: border-color .2s, box-shadow .2s;
  min-width: 0;
}
.pyth-input:focus { border-color:#FBBF24; box-shadow:0 0 0 3px rgba(251,191,36,.15); }
.pyth-input:disabled { opacity:0.5; }
.pyth-input::placeholder { color:rgba(245,158,11,0.38); }
.pyth-submit-btn {
  font-family:'Press Start 2P',cursive; font-size:0.55rem;
  padding:10px 18px; border:none; border-radius:10px;
  background:linear-gradient(135deg,#F59E0B,#FBBF24); color:var(--dark);
  cursor:pointer; flex-shrink:0; transition:transform .15s, box-shadow .15s;
  touch-action:manipulation; white-space:nowrap;
}
.pyth-submit-btn:hover:not(:disabled) { transform:scale(1.06); box-shadow:0 4px 14px rgba(245,158,11,.4); }
.pyth-submit-btn:disabled { opacity:0.4; cursor:default; }

.pyth-choices { display:flex; gap:12px; width:100%; flex-shrink:0; }
.pyth-choice {
  flex: 1;
  height: 66px;
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 14px;
  color: #fff;
  font-family: 'Press Start 2P', cursive;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all .14s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.pyth-choice:hover:not(:disabled) { background:rgba(245,158,11,0.18); border-color:#F59E0B; }
.pyth-choice:active:not(:disabled) { transform:scale(0.95); }
.pyth-choice.c-correct { background:rgba(78,205,196,0.25);  border-color:#4ECDC4; color:#4ECDC4; }
.pyth-choice.c-wrong   { background:rgba(255,107,107,0.2);  border-color:#FF6B6B; color:#FF6B6B; }
.pyth-choice:disabled  { cursor:default; }

.pyth-fb {
  font-family:'Press Start 2P',cursive; font-size:0.65rem;
  text-align:center; padding:10px 16px; border-radius:10px;
  width:100%; line-height:1.7;
}
.pyth-fb-correct { background:rgba(78,205,196,.2);  color:#4ECDC4; border:1px solid rgba(78,205,196,.4); }
.pyth-fb-close   { background:rgba(255,234,167,.15); color:#FFEAA7; border:1px solid rgba(255,234,167,.35); }
.pyth-fb-wrong   { background:rgba(255,107,107,.18); color:#FF6B6B; border:1px solid rgba(255,107,107,.35); }

@media (pointer: coarse) {
  .pyth-submit-btn { padding:12px 20px; min-height:44px; }
  .pyth-input { font-size:1.2rem; padding:12px 14px; }
  .pyth-choice { height:80px; font-size:1rem; }
}
