/* No scrolling, zooming, text selection or long-press menus (design D6). */
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #13679f;
  color: #fff;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
}

canvas {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

.panel {
  max-width: min(560px, 100%);
  max-height: 100%;
  overflow: auto;
  box-sizing: border-box;
  padding: clamp(12px, 3.5vmin, 28px) clamp(16px, 4.5vmin, 36px);
  border-radius: 20px;
  background: rgba(6, 34, 64, 0.8);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  text-align: center;
}

h1,
h2 {
  margin: 0 0 0.3em;
  font-size: clamp(30px, min(9vw, 11vh), 60px);
  line-height: 1.1;
  letter-spacing: 0.02em;
}

p {
  margin: 0 0 0.6em;
  font-size: clamp(15px, min(4.2vw, 4.8vh), 21px);
  line-height: 1.35;
}

.result {
  font-size: clamp(22px, min(6vw, 7vh), 34px);
  font-weight: 700;
}

.newbest {
  color: #ffd447;
  font-weight: 700;
}

.big {
  margin: 0;
  font-size: clamp(18px, min(5vw, 6vh), 28px);
  font-weight: 700;
}

.hint {
  margin: 0.5em 0 0;
  opacity: 0.75;
}

button {
  margin-top: 0.2em;
  padding: 0.4em 1.6em;
  border: 0;
  border-radius: 999px;
  background: #ffd447;
  color: #0a3a66;
  font: inherit;
  font-size: clamp(20px, min(6vw, 7vh), 30px);
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

button:active {
  transform: scale(0.96);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

/* Name field: the only place where typing, selection and the keyboard work. */
.name {
  display: block;
  margin: 0.2em 0 0.3em;
}

.name input {
  box-sizing: border-box;
  width: min(320px, 100%);
  padding: 0.35em 0.7em;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  background: #fff;
  color: #0a3a66;
  font: inherit;
  font-size: max(16px, min(4.6vw, 5vh, 22px)); /* 16px+ stops iOS zooming in */
  font-weight: 700;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
  touch-action: manipulation;
}

.name input::placeholder {
  color: #7a8ea3;
  font-weight: 400;
}

.name input:focus {
  outline: 3px solid #ffd447;
  outline-offset: 1px;
}

.name-note {
  margin: 0 0 0.5em;
  font-size: clamp(13px, min(3.6vw, 4vh), 16px);
  opacity: 0.8;
}

.name-note.error {
  color: #ffb0b0;
  font-weight: 700;
  opacity: 1;
}

/* Game over: result on the left, leaderboard on the right in landscape. */
.panel-wide {
  max-width: min(760px, 100%);
  overflow: auto;
}

.over-grid {
  display: grid;
  gap: 0.6em 1.6em;
  align-items: center;
}

@media (orientation: landscape) {
  .over-grid {
    grid-template-columns: auto minmax(220px, 1fr);
  }
}

.board {
  min-width: 0;
  text-align: left;
}

.board h3 {
  margin: 0 0 0.25em;
  font-size: clamp(16px, min(4.5vw, 5vh), 22px);
  text-align: center;
}

.board-status,
.board-you {
  margin: 0.2em 0;
  font-size: clamp(14px, min(3.8vw, 4.2vh), 18px);
  text-align: center;
  opacity: 0.85;
}

.board-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: clamp(14px, min(3.8vw, 4.2vh), 18px);
  line-height: 1.3;
}

.board-list li {
  display: grid;
  grid-template-columns: 2em 1fr auto;
  gap: 0.5em;
  padding: 0.05em 0.5em;
  border-radius: 8px;
}

.board-list li.you {
  background: rgba(255, 212, 71, 0.28);
  font-weight: 700;
}

.board-list .place {
  opacity: 0.7;
  text-align: right;
}

.board-list .who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-list .krill {
  font-variant-numeric: tabular-nums;
}

/* Instructions for the current device: touch on phones, keys elsewhere. */
.touch-only,
.tip {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .touch-only {
    display: block;
  }
  .keys-only {
    display: none;
  }
}

@media (hover: none) and (pointer: coarse) and (orientation: portrait) {
  .tip {
    display: block;
    opacity: 0.85;
  }
}

/* Pause button (design D19): top right of the HUD, only while running.
   main.js sets its position and size from the HUD layout. */
#pause-button {
  position: fixed;
  z-index: 1;
  margin: 0;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  background: rgba(8, 30, 55, 0.55);
}

#pause-button::before,
#pause-button::after {
  content: '';
  position: absolute;
  top: 28%;
  width: 14%;
  height: 44%;
  border-radius: 2px;
  background: #fff;
}

#pause-button::before {
  left: 30%;
}

#pause-button::after {
  right: 30%;
}
