/* Mondkrater - styles
 * Colours come from the drawing: night sky blue, moon dust grey, rover
 * orange. Cards look like the glass of a control panel floating in space.
 */

@font-face {
  font-family: 'Exo 2';
  src: url('assets/fonts/exo2-latin.woff2') format('woff2');
  font-weight: 100 900;
  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+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Exo 2';
  src: url('assets/fonts/exo2-latin-ext.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --nacht: #0b1024;
  --nacht-tief: #03050d;
  --karte: rgba(16, 22, 46, 0.93);
  --karte-rand: #34406e;
  --text: #eef1f8;
  --text-hell: #b4bcd4;
  --staub: #d9dce1;
  --staub-dunkel: #8b919e;
  --orange: #f28c28;
  --orange-hell: #ffad5c;
  --orange-dunkel: #9c4f0c;
  --signal: #5ef08f;
  --radius: 22px;
  --font: 'Exo 2', 'Trebuchet MS', system-ui, sans-serif;
  --hud-height: 60px;
  --bar-height: 70px;
  --side-width: 150px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--nacht);
  color: var(--text);
  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;
}

.field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.app[data-mode='play'] .field { cursor: pointer; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.35em;
  margin: 0 0.08em;
  border: 2px solid #4b578a;
  border-bottom-width: 3px;
  border-radius: 6px;
  background: #1b2347;
  color: var(--text);
  font: 600 0.8rem/1.45 var(--font), system-ui, sans-serif;
  text-align: center;
}
kbd.wide { min-width: 3.2em; }

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

.hud {
  position: absolute;
  top: var(--safe-top);
  left: 0;
  right: 0;
  height: var(--hud-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 max(12px, var(--safe-right)) 0 max(12px, var(--safe-left));
  pointer-events: none;
  z-index: 3;
}
.hud > * { pointer-events: auto; }

.hud-box {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 44px;
  padding: 0 14px 0 10px;
  background: rgba(12, 17, 38, 0.86);
  border: 2px solid var(--karte-rand);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.hud-icon { width: 24px; height: 24px; fill: var(--orange); flex: none; }
.hud-icon-line { fill: none; stroke: var(--staub); stroke-width: 1.6; stroke-linecap: round; }
.hud-value { font-size: 1.4rem; font-weight: 700; min-width: 2.4ch; font-variant-numeric: tabular-nums; }
.hud-size {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(12, 17, 38, 0.7);
  color: var(--text-hell);
  font-weight: 600;
}
.hud-size .practice {
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #33407a;
  color: var(--text);
  font-size: 0.8rem;
}
.hud-buttons { margin-left: auto; display: flex; gap: 10px; }

.round-button {
  width: 48px;
  height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid var(--karte-rand);
  background: rgba(12, 17, 38, 0.86);
  color: var(--text);
  cursor: pointer;
  padding: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.round-button svg { width: 24px; height: 24px; fill: currentColor; }
.round-button:hover { border-color: var(--orange); }
.round-button:active { transform: translateY(1px); }
.fullscreen-button .icon-exit { display: none; }
.is-fullscreen .fullscreen-button .icon-enter { display: none; }
.is-fullscreen .fullscreen-button .icon-exit { display: block; }

/* ---------------------------------------------------------------- bottom bar */

.bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--safe-bottom);
  height: var(--bar-height);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 max(12px, var(--safe-right)) 0 max(12px, var(--safe-left));
  pointer-events: none;
  z-index: 3;
}
.bar > * { pointer-events: auto; }

.tool-switch {
  display: flex;
  padding: 4px;
  gap: 4px;
  background: rgba(12, 17, 38, 0.9);
  border: 2px solid var(--karte-rand);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.tool {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-hell);
  font: 700 1rem var(--font);
  cursor: pointer;
}
.tool svg { width: 26px; height: 26px; fill: currentColor; }
.tool svg .tool-wheel { fill: var(--orange); }
.tool[aria-pressed='true'] .tool-wheel { fill: #1b1205; }
.tool:hover { color: var(--text); }
.tool[aria-pressed='true'] {
  background: var(--orange);
  color: #1b1205;
  box-shadow: inset 0 -3px 0 var(--orange-dunkel);
}
.tool[aria-pressed='true'] .hud-icon-line { stroke: #1b1205; }

/* Keyboard hints during play: left and right of the tool switch, only
   for keyboard users on screens wide enough for them. */
.bar .play-keys {
  display: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  flex-wrap: nowrap;
  white-space: nowrap;
  gap: 4px 14px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(12, 17, 38, 0.86);
  border: 2px solid var(--karte-rand);
  color: var(--text);
  font-size: 0.8rem;
}
.bar .play-keys-left { left: max(16px, var(--safe-left)); }
.bar .play-keys-right { right: max(16px, var(--safe-right)); }
@media (min-width: 980px) and (hover: hover) {
  .app.keyboard .bar .play-keys { display: flex; }
}

/* Flat landscape phones: HUD and tools as a column on the left. */
.app.side .hud {
  flex-direction: column;
  align-items: stretch;
  width: var(--side-width);
  height: auto;
  right: auto;
  top: calc(var(--safe-top) + 8px);
  left: max(6px, var(--safe-left));
  padding: 0;
  gap: 8px;
}
.app.side .hud-size { text-align: center; font-size: 0.9rem; }
.app.side .hud-buttons { margin: 0; justify-content: center; }
.app.side .bar {
  left: max(6px, var(--safe-left));
  right: auto;
  width: var(--side-width);
  height: auto;
  bottom: calc(var(--safe-bottom) + 8px);
  flex-direction: column;
  padding: 0;
  gap: 8px;
}
.app.side .tool-switch { flex-direction: column; border-radius: 26px; width: 100%; }
.app.side .tool { padding: 0 10px; font-size: 0.95rem; }
.app.side .tool { justify-content: flex-start; }
.app.side .zoom-button { align-self: center; }
.app.side .bar .play-keys { display: none; }

/* ---------------------------------------------------------------- notes */

.start-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + var(--bar-height) + 10px);
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  pointer-events: none;
  z-index: 2;
}
.start-hint p {
  margin: 0;
  padding: 10px 18px;
  border-radius: 16px;
  background: rgba(12, 17, 38, 0.9);
  border: 2px solid var(--karte-rand);
  font-weight: 600;
  text-align: center;
  animation: hint-in 0.4s ease-out both;
}
.app.side .start-hint { bottom: calc(var(--safe-bottom) + 10px); left: calc(50% + var(--side-width) / 2); }
@keyframes hint-in { from { opacity: 0; transform: translateY(8px); } }

.toast {
  position: absolute;
  top: calc(var(--safe-top) + var(--hud-height) + 12px);
  left: 50%;
  transform: translate(-50%, -8px);
  max-width: calc(100% - 32px);
  width: max-content;
  padding: 10px 18px;
  border-radius: 16px;
  background: rgba(12, 17, 38, 0.95);
  border: 2px solid var(--orange);
  color: var(--text);
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 6;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.app.side .toast { top: calc(var(--safe-top) + 12px); left: calc(50% + var(--side-width) / 2); }

.back-to-card {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 18px);
  transform: translateX(-50%);
  z-index: 4;
}

/* ---------------------------------------------------------------- screens */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 16px) max(16px, var(--safe-right)) calc(var(--safe-bottom) + 16px) max(16px, var(--safe-left));
  overflow-y: auto;
  z-index: 5;
}
#screen-pause, #screen-over { background: rgba(3, 5, 13, 0.35); }

.card {
  width: min(520px, 100%);
  margin: auto;
  padding: 22px 24px 18px;
  background: var(--karte);
  border: 2px solid var(--karte-rand);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  text-align: center;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: card-in 0.3s ease-out both;
}
.card-small { width: min(380px, 100%); }
@keyframes card-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

h1, h2 { margin: 0 0 10px; font-weight: 800; letter-spacing: 0.01em; }
h2 { font-size: 1.7rem; }
.logo {
  font-size: clamp(2.4rem, 9vw, 3.4rem);
  line-height: 1;
  color: var(--text);
  text-shadow: 0 3px 0 #1d2650, 0 0 24px rgba(120, 150, 255, 0.35);
}
.title-pic { display: block; width: 200px; height: 78px; margin: -10px auto 4px; }
.tagline { margin: 6px 0 14px; color: var(--text-hell); font-size: 1.05rem; }
.muted { color: var(--text-hell); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 22px;
  border: 0;
  border-radius: 16px;
  background: var(--staub);
  color: #141b38;
  font: 700 1.05rem var(--font);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--staub-dunkel);
  transition: filter 0.15s;
}
.button:hover { filter: brightness(1.08); }
.button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--staub-dunkel); }
.button:disabled { opacity: 0.6; cursor: default; }
.button-start {
  background: var(--orange);
  color: #1b1205;
  box-shadow: 0 4px 0 var(--orange-dunkel);
  font-size: 1.2rem;
  min-width: 170px;
}
.button-start:active { box-shadow: 0 1px 0 var(--orange-dunkel); }
.button-wide { width: 100%; margin-bottom: 14px; flex-wrap: wrap; }
.button-note { font-weight: 600; font-size: 0.9rem; opacity: 0.85; }
.button-quiet {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--karte-rand);
  box-shadow: none;
  min-height: 46px;
}
.button-quiet:active { box-shadow: none; }
.button-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.card > .button { margin-top: 6px; }
#screen-pause .button { display: flex; width: 100%; margin-top: 12px; }

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid #ffd27a;
  outline-offset: 3px;
}

.link-button {
  border: 0;
  background: none;
  padding: 4px 2px;
  color: var(--orange-hell);
  font: 700 1rem var(--font);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Size choice */
.sizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.size-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border: 2px solid var(--karte-rand);
  border-radius: 16px;
  background: rgba(27, 35, 71, 0.85);
  color: var(--text);
  font-family: var(--font);
  cursor: pointer;
}
.size-chip:hover { border-color: var(--orange-hell); }
.size-chip[aria-pressed='true'] {
  border-color: var(--orange);
  background: rgba(242, 140, 40, 0.18);
  box-shadow: 0 0 0 2px var(--orange), 0 0 18px rgba(242, 140, 40, 0.35);
}
.chip-name { font-weight: 800; font-size: 1.15rem; }
.chip-dim { font-size: 0.78rem; line-height: 1.2; color: var(--text-hell); }
.chip-info { margin-top: 3px; font-size: 0.8rem; color: var(--orange-hell); font-weight: 600; min-height: 1.2em; }

/* Switches */
.switches { display: flex; flex-wrap: wrap; gap: 2px 16px; justify-content: center; margin-top: 12px; }
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 6px;
  border: 0;
  background: none;
  color: var(--text);
  font: 600 0.95rem var(--font);
  cursor: pointer;
}
.switch-track {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #2a3463;
  border: 2px solid #4b578a;
  transition: background 0.2s;
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--staub);
  transition: transform 0.2s;
}
.switch[aria-checked='true'] .switch-track { background: var(--orange); border-color: var(--orange-hell); }
.switch[aria-checked='true'] .switch-thumb { transform: translateX(20px); background: #fff; }

.key-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  justify-content: center;
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--text-hell);
}
/* Keyboard hints make no sense on touch screens */
@media (hover: none) and (pointer: coarse) {
  .title-keys, .help-keys, .key-hint-line { display: none; }
}

.storage-hint {
  margin: 12px 0 0;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(27, 35, 71, 0.9);
  color: var(--text-hell);
  font-size: 0.82rem;
}

.title-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--karte-rand);
  font-size: 0.9rem;
}
.title-links a { color: var(--text-hell); text-underline-offset: 3px; }
.title-links a:hover { color: var(--text); }
.back-link { font-weight: 700; color: var(--orange-hell) !important; }
.legal { display: flex; gap: 14px; }

/* Help */
.help-list { list-style: none; margin: 8px 0 6px; padding: 0; text-align: left; }
.help-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(52, 64, 110, 0.6);
}
.help-list li:last-child { border-bottom: 0; }
.help-pic {
  width: 72px;
  height: 56px;
  flex: none;
  border-radius: 12px;
  background: #b9bcc2;
}

/* Leaderboard */
.tabs { display: flex; gap: 6px; justify-content: center; margin: 4px 0 12px; }
.tab {
  flex: 1;
  min-height: 44px;
  border: 2px solid var(--karte-rand);
  border-radius: 12px;
  background: transparent;
  color: var(--text-hell);
  font: 700 1rem var(--font);
  cursor: pointer;
}
.tab[aria-selected='true'] { background: var(--orange); border-color: var(--orange); color: #1b1205; }
.score-list {
  min-height: 140px;
  max-height: min(52vh, 460px);
  overflow-y: auto;
  border-radius: 14px;
  background: rgba(8, 12, 28, 0.6);
  padding: 6px;
}
.score-empty { padding: 30px 10px; margin: 0; }
.score-table { list-style: none; margin: 0; padding: 0; }
.score-table li {
  display: grid;
  grid-template-columns: 2.4em 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 7px 10px;
  border-radius: 10px;
  text-align: left;
}
.score-table li:nth-child(odd) { background: rgba(255, 255, 255, 0.04); }
.score-table li.mine { background: rgba(242, 140, 40, 0.25); box-shadow: inset 0 0 0 2px var(--orange); }
.score-rank { font-weight: 800; color: var(--text-hell); text-align: right; }
.score-table li:nth-child(-n + 3) .score-rank { color: var(--orange-hell); }
.score-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.score-points { font-weight: 800; font-variant-numeric: tabular-nums; }
.own-best { min-height: 1.3em; margin: 10px 0 4px; color: var(--text-hell); font-size: 0.95rem; }

.key-hint-line { margin: 10px 0 0; color: var(--text-hell); font-size: 0.85rem; }

/* End card */
.card-over { width: min(460px, 100%); }
.over-pic { display: block; width: 220px; height: 96px; margin: -8px auto 2px; }
.over-time {
  margin: 0;
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--orange-hell);
}
.over-sub { margin: 4px 0 0; color: var(--text-hell); }
.over-progress {
  height: 14px;
  margin: 10px auto 0;
  max-width: 280px;
  border-radius: 999px;
  background: #2a3463;
  overflow: hidden;
}
.over-progress-bar {
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: linear-gradient(90deg, var(--orange), var(--orange-hell));
  border-radius: 999px;
}
.over-note { min-height: 1.3em; margin: 10px 0 0; font-weight: 600; }
.over-note.record { color: var(--signal); }
.over-tip {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(27, 35, 71, 0.9);
  border: 1px dashed var(--karte-rand);
  color: var(--text-hell);
  font-size: 0.85rem;
  text-align: left;
}
.over-tip strong { color: var(--text); }
.over-buttons { margin-top: 10px; }
.over-buttons .button { flex: 1; min-width: 150px; }
.over-buttons .button-quiet { min-height: 42px; font-size: 0.95rem; }

.name-form { margin-top: 10px; padding: 10px 12px; border-radius: 16px; background: rgba(242, 140, 40, 0.12); border: 2px solid rgba(242, 140, 40, 0.5); }
.name-title { margin: 0 0 6px; font-weight: 800; color: var(--orange-hell); }
.name-label { display: block; font-size: 0.9rem; color: var(--text-hell); margin-bottom: 6px; }
.name-row { display: flex; gap: 8px; }
.name-row input {
  flex: 1;
  min-width: 0;
  min-height: 50px;
  padding: 0 14px;
  border: 2px solid var(--karte-rand);
  border-radius: 14px;
  background: #0b1024;
  color: var(--text);
  font: 700 1.1rem var(--font);
  user-select: text;
  -webkit-user-select: text;
}
.button-send { min-width: 0; padding: 0 16px; }
.name-message { min-height: 1.2em; margin: 6px 0 0; font-weight: 600; color: var(--orange-hell); }
.name-message.ok { color: var(--signal); }
.name-privacy { margin: 4px 0 0; font-size: 0.74rem; line-height: 1.3; color: var(--text-hell); }
.scores-offline { margin: 12px 0 0; color: var(--text-hell); font-size: 0.92rem; }

.noscript { position: absolute; inset: auto 0 40% 0; text-align: center; font-size: 1.3rem; }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 480px) {
  body { font-size: 17px; }
  .card { padding: 20px 16px 16px; }
  .chip-dim { font-size: 0.7rem; }
  .tool { padding: 0 14px 0 10px; }
  .hud-box { padding: 0 10px 0 8px; gap: 5px; }
  .hud-size { display: none; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .card-title { width: min(780px, 100%); display: grid; grid-template-columns: 1fr 1.15fr; gap: 0 24px; align-items: start; }
  .card-title > .title-pic, .card-title .key-hints { display: none; }
  .card-title > .logo { grid-column: 1; grid-row: 1; font-size: 2.4rem; margin-top: 8px; }
  .card-title > .tagline { grid-column: 1; grid-row: 2; font-size: 0.95rem; }
  .card-title > .storage-hint { grid-column: 1; grid-row: 3 / span 2; }
  .card-title > .title-links { grid-column: 1; grid-row: 5; }
  .card-title > #continue-button { grid-column: 2; grid-row: 1; margin-bottom: 8px; }
  .card-title > .sizes { grid-column: 2; grid-row: 2; margin-bottom: 8px; }
  .card-title > #start-button { grid-column: 2; grid-row: 3; justify-self: center; }
  .card-title > .button-row { grid-column: 2; grid-row: 4; margin-top: 8px; }
  .card-title > .switches { grid-column: 2; grid-row: 5; margin-top: 6px; }
}

/* ---------------------------------------------------------------- reduced motion */
/* data-ruhig on <html>: set from the switch, default from the system. */
html[data-ruhig='1'] *,
html[data-ruhig='1'] *::before,
html[data-ruhig='1'] *::after {
  animation: none !important;
  transition: none !important;
}
