html, body, #root {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #dff2f8;
  font-family: Arial, sans-serif;
}
/* During a run nothing on the page selects or opens a callout, not even the
   page around the game (iOS reads stray long presses and multi-finger
   touches as text gestures otherwise); typing and copyable text still work. */
html.in-play, html.in-play body {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
html.in-play :is(input, textarea, [contenteditable]:not([contenteditable="false"]), [data-twinkle-selectable]) {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}
.container {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  box-sizing: border-box;
}
.game-shell {
  -webkit-touch-callout: none;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: min(900px, 96%);
  margin-inline: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 12px;
  container-type: inline-size;
}
canvas {
  display: block;
  width: 100%;
  margin-inline: auto;
  height: auto;
  box-sizing: border-box;
  background: #bfe9ff;
  border: 3px solid #14344f;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 12px 28px rgba(16, 42, 67, 0.2);
}
.is-starting canvas {
  border-radius: 12px;
}
.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-width: calc(100% - 24px);
}
.stat {
  display: grid;
  gap: 1px;
  min-width: 70px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,0.56);
  border-radius: 8px;
  background: rgba(10, 31, 51, 0.72);
  color: white;
  box-shadow: 0 4px 12px rgba(6, 20, 34, 0.18);
}
.stat span, .leaderboard-status, .empty-board, .leaderboard-list small {
  color: #b8d8ec;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.stat strong { font-size: 18px; line-height: 1; }
.leaderboard-card {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(250px, 36%);
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: 10px;
  background: rgba(8, 24, 40, 0.76);
  color: white;
  box-shadow: 0 4px 16px rgba(6, 20, 34, 0.18);
}
.panel-title {
  color: #ffdc6b;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.board-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.board-tabs { display: flex; gap: 4px; }
.board-tab {
  padding: 3px 9px;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 999px;
  background: transparent;
  color: #b8d8ec;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}
.board-tab.is-active { background: #ffdc6b; border-color: #ffdc6b; color: #2a1d00; }
.leaderboard-status { margin: 5px 0 8px; text-transform: none; letter-spacing: 0; }
.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.leaderboard-list li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  font-size: 13px;
}
.leaderboard-list { align-content: start; }
.rank { color: #ffdc6b; font-weight: 900; }
.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: #102a43;
  border: 3px solid #14344f;
  border-top: 0;
  border-radius: 0 0 12px 12px;
  box-sizing: border-box;
  min-width: 0;
  overflow: hidden;
}
.control-note {
  flex: 1 1 auto;
  min-width: 0;
  color: #d7e9f5;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.stat-mute { min-width: 0; }
.stat-replay strong { display: block; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #ffd65c; }
.btn:active { transform: translateY(1px); }
.title-screen {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  overflow: hidden;
  box-sizing: border-box;
  padding: 20px 24px 18px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(rgba(191, 233, 255, 0.1), rgba(191, 233, 255, 0.04));
  color: white;
  font-family: "Courier New", monospace;
  text-transform: uppercase;
}
.title-screen:focus-visible {
  outline: 4px solid #ffd65c;
  outline-offset: 4px;
}
.title-sign {
  position: relative;
  z-index: 2;
  justify-self: center;
  width: min(620px, 82%);
  box-sizing: border-box;
  padding: 16px 20px;
  border: 4px solid #4f171c;
  background: #cc4b44;
  box-shadow: 8px 8px 0 rgba(20, 52, 79, 0.34);
}
/* Corner pegs: one strip per side, painted only at its two ends, so they hug
   the corners whether the title takes one line or two. */
.title-sign::before,
.title-sign::after {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 8px;
  background: linear-gradient(#f7d8cf 0 8px, transparent 8px calc(100% - 8px), #f7d8cf calc(100% - 8px));
}
.title-sign::before { left: 8px; }
.title-sign::after { right: 8px; }
.title-sign h1 {
  margin: 0;
  color: #fff4f4;
  font-size: 2rem;
  line-height: 0.95;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 5px 5px 0 #24364f;
}
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  justify-items: center;
  align-items: start;
  background: rgba(4, 15, 26, 0.42);
  border-radius: 12px;
}
.overlay-card {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 10px;
  width: min(520px, 86%);
  max-height: 88%;
  min-height: 0;
  margin-top: var(--overlay-card-margin-top, 0);
  box-sizing: border-box;
  overflow: hidden;
  padding: 22px;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 10px;
  background: rgba(8, 24, 40, 0.92);
  color: white;
  text-align: center;
}
.overlay-card h1 { margin: 6px 0; font-size: 34px; }
.overlay-card p { margin: 0; color: #c8ddeb; font-weight: 700; }
.overlay-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.btn { padding: 10px 18px; background: #d7e9f5; color: #102a43; }
.btn-primary { background: #ffd65c; color: #2a1d00; }
.btn-quiet { background: rgba(255, 255, 255, 0.14); color: #fff; border: 1px solid rgba(255, 255, 255, 0.4); }
.title-screen.has-art { background-size: cover; background-position: center; }

/* Title menu */
.title-menu-slot { align-self: center; justify-self: center; display: grid; justify-items: center; gap: 12px; width: 100%; }
.title-menu { display: grid; gap: 10px; width: min(340px, 72%); text-transform: none; }
.menu-item {
  position: relative;
  min-height: 52px;
  padding: 10px 22px;
  border: 3px solid #14344f;
  border-radius: 10px;
  background: rgba(8, 24, 40, 0.82);
  color: #fff;
  font-family: "Courier New", monospace;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 5px 5px 0 rgba(20, 52, 79, 0.4);
}
.menu-item.is-active { background: #ffd65c; color: #2a1d00; border-color: #4f171c; }
.menu-item.is-active::before { content: "\25B6"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 0.8em; }
.menu-item:active { transform: translateY(2px); box-shadow: 3px 3px 0 rgba(20, 52, 79, 0.4); }
/* Ranked run shares its row with a smaller Replays button (ranked run replays). */
.menu-split { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 3fr); gap: 8px; }
.menu-item.menu-side { padding: 6px 6px; font-size: 0.8rem; letter-spacing: 0; white-space: nowrap; background: rgba(20, 70, 100, 0.9); border-color: #1e5a7c; }
.menu-item.menu-side.is-active { background: #56d6ff; color: #04263a; border-color: #0c4058; }
.menu-item.menu-side.is-active::before { content: none; }
/* Same small label on every layout (the compact page's menu rule is bigger). */
.title-screen .title-menu .menu-item.menu-side { font-size: 0.8rem; overflow: hidden; }
.menu-hint { margin: 0; padding: 4px 12px; border-radius: 999px; background: rgba(8, 24, 40, 0.72); color: #fff; font-size: 12px; font-weight: 700; text-transform: none; }
.uses-touch .menu-hint { display: none; }

/* End card and the quit question */
.overlay { align-items: center; }
.overlay-card { grid-template-rows: none; margin-top: 0; }
.overlay-rank { color: #ffdc6b !important; min-height: 1.2em; }
.menu-panel-actions { display: flex; justify-content: center; gap: 10px; }
.menu-panel-actions .btn { min-height: 44px; padding: 8px 22px; font-size: 1rem; }
.hud-menu-button { min-height: 36px; padding: 0 14px; border: 2px solid rgba(255, 255, 255, 0.55); border-radius: 8px; background: rgba(8, 24, 40, 0.72); color: #fff; font: inherit; font-size: 12px; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; touch-action: manipulation; }
.hud-menu-button:hover { background: rgba(20, 52, 79, 0.9); }
.quit-confirm { position: fixed; z-index: 40; border-radius: 0; background: rgba(4, 15, 26, 0.8); }
.quit-confirm .overlay-card { width: min(420px, 90%); max-height: 96%; overflow-y: auto; }
.quit-confirm .overlay-card p { color: #fff; font-size: 15px; line-height: 1.4; }
.quit-keys { justify-self: center; background: none; color: #9fc0d6 !important; font-size: 12px !important; }
.uses-touch .quit-keys { display: none; }
.uses-touch .controls { display: none; }
/* Pause card: the highlighted choice (keyboard) gets a bright ring. */
.quit-confirm .btn.is-active { outline: 3px solid #ffd65c; outline-offset: 2px; }

/* While playing, a resting mouse pointer is hidden (game/cursor-hide.js). */
.container.hide-cursor,
.container.hide-cursor * { cursor: none !important; }
