/* Faultier-Pong - styles
 * Colours come from the drawing: jungle greens, bark brown, mango orange.
 * Cards look like soft paper hanging in the jungle (same family as the
 * other fun games, own colours).
 */

@font-face {
  font-family: 'Grandstander';
  src: url('assets/fonts/grandstander-latin.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Grandstander';
  src: url('assets/fonts/grandstander-latin-ext.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --dschungel: #1d3b26;
  --dschungel-tief: #12271a;
  --blatt: #4f8a3a;
  --blatt-dunkel: #24402a;
  --papier: #fbf5e6;
  --papier-rand: #e6dbbd;
  --papier-tief: #f2ead3;
  --tinte: #2b1e14;
  --tinte-hell: #5f5446;
  --rinde: #7b5a3a;
  --mango: #f59a2c;
  --mango-hell: #ffb44f;
  --mango-dunkel: #b8611a;
  --schatten: rgba(10, 25, 14, 0.4);
  --radius: 22px;
  --font: 'Grandstander', 'Trebuchet MS', system-ui, sans-serif;
  --hud-height: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--dschungel-tief);
  color: var(--tinte);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: radial-gradient(ellipse at 50% 30%, #2f5d36, var(--dschungel) 60%, var(--dschungel-tief));
}

.field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

[hidden] { display: none !important; }

/* While playing, fingers on the field steer: no scrolling, no zooming. */
.app[data-mode='play'] .field { touch-action: none; }

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

.hud {
  position: absolute;
  top: var(--safe-top);
  left: 0;
  right: 0;
  height: var(--hud-height);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
  pointer-events: none;
  z-index: 3;
}
.hud > * { pointer-events: auto; }
.score {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 2px 18px;
  background: rgba(251, 245, 230, 0.94);
  border: 3px solid var(--blatt-dunkel);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--blatt-dunkel);
}
.score-name { font-size: 0.8rem; color: var(--tinte-hell); font-weight: 600; }
.score-num { font-size: 1.6rem; font-weight: 800; min-width: 1.2ch; text-align: center; font-variant-numeric: tabular-nums; }
.score-sep { font-size: 1.4rem; font-weight: 800; color: var(--tinte-hell); }
.hud-buttons {
  position: absolute;
  right: max(12px, env(safe-area-inset-right, 0px));
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 8px;
}

.round-button {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 3px solid var(--blatt-dunkel);
  background: var(--papier);
  box-shadow: 0 3px 0 var(--blatt-dunkel);
  color: var(--blatt-dunkel);
  cursor: pointer;
  padding: 0;
}
.round-button svg { width: 22px; height: 22px; fill: currentColor; }
.round-button:hover { background: #fffbef; }
.round-button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--blatt-dunkel); }
.fullscreen-button .icon-exit { display: none; }
.is-fullscreen .fullscreen-button .icon-enter { display: none; }
.is-fullscreen .fullscreen-button .icon-exit { display: block; }

.rally {
  position: absolute;
  top: calc(var(--safe-top) + var(--hud-height) + 4px);
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 14px;
  border-radius: 999px;
  background: rgba(36, 64, 42, 0.85);
  color: var(--papier);
  font-weight: 700;
  font-size: 0.9rem;
  z-index: 3;
  pointer-events: none;
}

.toast {
  position: absolute;
  top: calc(var(--safe-top) + var(--hud-height) + 34px);
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 6px 18px;
  border-radius: 999px;
  background: var(--mango);
  border: 3px solid var(--mango-dunkel);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 4;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* While playing with a mouse, the pointer hides after a moment of rest. */
.app.cursor-hidden, .app.cursor-hidden * { cursor: none !important; }

/* Hint before the first serve */
.overlay {
  position: absolute;
  inset: auto 0 calc(20px + var(--safe-bottom)) 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 4;
  padding: 0 16px;
}
.bubble {
  margin: 0;
  max-width: 520px;
  padding: 10px 20px;
  border-radius: 18px;
  background: rgba(251, 245, 230, 0.95);
  border: 3px solid var(--blatt-dunkel);
  font-weight: 600;
  text-align: center;
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-6px); } }

/* Upright screen while playing */
.rotate-hint {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 22, 12, 0.75);
  text-align: center;
}
.rotate-icon { width: 72px; height: 72px; fill: none; stroke: var(--blatt-dunkel); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------- Screens */

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: start center;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  overflow-y: auto;
  z-index: 5;
  background: rgba(8, 22, 12, 0.3);
}

.card {
  margin-block: auto;
  width: min(540px, 100%);
  background: var(--papier);
  border: 4px solid var(--blatt-dunkel);
  border-radius: var(--radius);
  box-shadow: 0 8px 0 var(--blatt-dunkel), 0 18px 40px var(--schatten);
  padding: 22px 24px 20px;
  text-align: center;
}
.card > * + * { margin-top: 14px; }

h2 { margin: 0; font-size: 1.8rem; color: var(--blatt-dunkel); }

.logo {
  margin: 0;
  font-size: clamp(2.4rem, 8.5vw, 3.6rem);
  font-weight: 800;
  line-height: 1;
  color: var(--mango);
  letter-spacing: 0.01em;
  text-shadow: 0 3px 0 var(--mango-dunkel), 0 6px 0 rgba(43, 30, 20, 0.25);
}
.tagline { margin-top: 8px; color: var(--tinte-hell); }

/* ------------------------------------------------------------- Choices */

.choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice-mode { grid-template-columns: 1fr 1fr; margin-top: 18px; }
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  padding: 6px 4px;
  border: 3px solid var(--papier-rand);
  border-radius: 14px;
  background: var(--papier-tief);
  color: var(--tinte);
  font: 600 1rem/1.1 var(--font);
  cursor: pointer;
}
.chip-big { min-height: 60px; }
.chip-big .chip-name { font-size: 1.2rem; font-weight: 700; }
.chip-small { min-height: 40px; font-size: 0.9rem; }
.chip:hover { border-color: #cbbd95; }
.chip[aria-pressed='true'] {
  border-color: var(--blatt-dunkel);
  background: #dcebc6;
  box-shadow: inset 0 -3px 0 rgba(36, 64, 42, 0.25);
}
.chip-info { font-size: 0.75rem; font-weight: 400; color: var(--tinte-hell); }
.chip-info:empty { display: none; }
.app[data-choice-mode='duo'] .choice-level { visibility: hidden; }

/* ------------------------------------------------------------- Buttons */

.button {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 18px;
  border: 3px solid var(--blatt-dunkel);
  border-radius: 16px;
  background: var(--papier);
  color: var(--blatt-dunkel);
  font: 600 1.1rem/1.2 var(--font);
  box-shadow: 0 4px 0 var(--blatt-dunkel);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
.button:hover { background: #fffbef; }
.button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--blatt-dunkel); }

.button-start {
  min-height: 60px;
  font-size: 1.6rem;
  font-weight: 800;
  background: var(--mango);
  border-color: var(--mango-dunkel);
  color: #3a1f04;
  box-shadow: 0 5px 0 var(--mango-dunkel);
}
.button-start:hover { background: var(--mango-hell); }
.button-start:active { box-shadow: 0 2px 0 var(--mango-dunkel); }

.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.link-button {
  border: 0;
  background: none;
  padding: 0 0 0 4px;
  font: inherit;
  font-weight: 700;
  color: var(--blatt-dunkel);
  text-decoration: underline;
  cursor: pointer;
}

:focus-visible {
  outline: 4px solid #2f7fd0;
  outline-offset: 3px;
}

.records { font-size: 0.85rem; color: var(--tinte-hell); }
.start-group { display: grid; gap: 6px; justify-items: center; }
.new-button { font-size: 0.9rem; }

.card-small { width: min(380px, 100%); }

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

.help-list {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  text-align: left;
  display: grid;
  gap: 12px;
}
.help-list li { display: flex; align-items: center; gap: 14px; }
.help-pic { flex: none; width: 72px; height: 56px; border-radius: 10px; }

/* ---------------------------------------------------------------- End */

.screen-over { background: rgba(8, 22, 12, 0.15); }
.card-over { width: min(420px, 100%); }
.card-over > * + * { margin-top: 8px; }
.over-score { font-size: 2.6rem; font-weight: 800; color: var(--blatt-dunkel); margin-bottom: 0; line-height: 1.1; font-variant-numeric: tabular-nums; }
.over-stats { font-size: 0.9rem; color: var(--tinte-hell); }
.over-note { font-weight: 700; color: var(--mango-dunkel); min-height: 1.2em; }
.over-buttons { margin-top: 14px !important; }

/* ------------------------------------------------------------ Switches */

.switches { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; }
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  background: none;
  color: var(--tinte);
  font: 500 0.95rem var(--font);
  cursor: pointer;
  padding: 0 4px;
}
.switch-track {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #cfc6ad;
  border: 2px solid var(--blatt-dunkel);
  transition: background 0.15s;
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--papier);
  border: 2px solid var(--blatt-dunkel);
  transition: transform 0.15s;
}
.switch[aria-checked='true'] .switch-track { background: var(--blatt); }
.switch[aria-checked='true'] .switch-thumb { transform: translateX(20px); }

.storage-hint {
  font-size: 0.85rem;
  color: var(--tinte-hell);
  background: var(--papier-tief);
  border-radius: 12px;
  padding: 8px 12px;
}

.title-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}
.title-links a { color: var(--blatt-dunkel); }
.back-link { font-weight: 700; }
.back-link::before { content: '← '; }
.legal { display: flex; gap: 12px; }
.legal a { color: var(--tinte-hell); }

/* ------------------------------------------- Keyboard hints (desktop) */

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  border-radius: 5px;
  background: var(--papier);
  color: var(--blatt-dunkel);
  font: 700 0.75rem var(--font);
  box-shadow: 0 2px 0 #b5ab8c;
  border: 1px solid #cfc5a6;
}
kbd.wide { padding: 0 8px; }
.key-hints, .key-hint-line { display: none; }
@media (hover: hover) and (pointer: fine) {
  .key-hints {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 16px;
    font-size: 0.8rem;
    color: var(--tinte-hell);
  }
  .key-hints span { display: inline-flex; align-items: center; gap: 3px; }
  .key-hint-line { display: block; font-size: 0.85rem; color: var(--tinte-hell); }
}

.noscript { position: absolute; inset: 40% 16px auto; text-align: center; color: var(--papier); }

/* ------------------------------------------------- Small and low screens */

@media (max-width: 420px) {
  html, body { font-size: 16px; }
  .card { padding: 18px 16px 16px; }
}

/* Laptops with little height: a more compact title card */
@media (max-height: 820px) and (min-height: 521px) {
  .card { padding: 16px 22px 14px; }
  .card > * + * { margin-top: 10px; }
  .logo { font-size: 3rem; }
  .choice-mode { margin-top: 12px; }
  .chip-big { min-height: 52px; }
  .button-start { min-height: 54px; }
  .switches { gap: 0 16px; }
  .switch { min-height: 38px; }
}

/* Phones held sideways: two columns so the title fits without scrolling */
@media (max-height: 520px) and (orientation: landscape) {
  :root { --hud-height: 42px; }
  html, body { font-size: 15px; }
  .round-button { width: 38px; height: 38px; }
  .score { padding: 0 14px; }
  .score-num { font-size: 1.3rem; }
  .help-list { gap: 4px; font-size: 0.85rem; margin-top: 8px; }
  .help-pic { width: 54px; height: 42px; }
  .screen { padding-top: calc(8px + var(--safe-top)); padding-bottom: calc(8px + var(--safe-bottom)); }
  .card { padding: 12px 18px 10px; box-shadow: 0 5px 0 var(--blatt-dunkel), 0 12px 30px var(--schatten); }
  .card > * + * { margin-top: 8px; }
  .card-title {
    width: min(800px, 100%);
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 8px 22px;
    align-items: center;
    text-align: left;
  }
  .card-title > * + * { margin-top: 0; }
  .card-title .logo { grid-column: 1; grid-row: 1; font-size: 2.3rem; }
  .card-title .tagline { grid-column: 1; grid-row: 2; margin: 0; font-size: 0.85rem; }
  .card-title .choice-mode { grid-column: 1; grid-row: 3; margin: 0; }
  .card-title .choice-level { grid-column: 1; grid-row: 4; }
  .card-title .choice-tempo { grid-column: 1; grid-row: 5; }
  .card-title .button-start { min-height: 56px; }
  .card-title .start-group { grid-column: 2; grid-row: 1 / span 2; }
  .card-title [data-go='help'] { grid-column: 2; grid-row: 3; }
  .card-title .records { display: none; }
  .card-title .switches { grid-column: 2; grid-row: 4; justify-content: flex-start; gap: 0 10px; }
  .card-title .title-links { grid-column: 2; grid-row: 5; }
  .card-title .storage-hint { grid-column: 1 / -1; grid-row: 6; padding: 4px 10px; font-size: 0.8rem; }
  .card-title .key-hints { display: none; }
  .chip-big { min-height: 48px; }
  .chip { min-height: 40px; }
  .button { min-height: 44px; padding: 6px 14px; }
}

/* Big monitors and boards: everything a bit larger */
@media (min-width: 1600px) and (min-height: 900px) {
  :root { --hud-height: 64px; }
  html, body { font-size: 21px; }
  .round-button { width: 54px; height: 54px; }
  .card { width: min(620px, 100%); }
}

/* Less motion: no animations, no transitions */
[data-ruhig='1'] *, [data-ruhig='1'] *::before, [data-ruhig='1'] *::after {
  animation: none !important;
  transition: none !important;
}
