html, body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  width: 100%;
  height: 100%;
  background: #04283d;
  font-family: 'Segoe UI', Arial, sans-serif;
  cursor: default;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
canvas {
  display: block;
  touch-action: none;
}
#hud {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  font-size: 18px;
  line-height: 1.5;
  pointer-events: none;
}
#hud .size {
  font-size: 26px;
  font-weight: bold;
}
#hud .difficulty {
  font-size: 14px;
  opacity: 0.8;
}
#bars {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  text-align: right;
  font-size: 14px;
  pointer-events: none;
}
/* Under the bars, right-aligned: the FPS counter, then the pause button (the only part of #bars that takes clicks) */
#pauseRow {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 2px;
}
#fps {
  font-size: 12px;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}
#pauseBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  background: rgba(0,0,0,0.35);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
}
#pauseBtn svg {
  display: block;
  fill: #fff;
}
#pauseBtn:hover {
  background: rgba(0,0,0,0.55);
}
#pauseBtn[hidden] {
  display: none;
}
.barBg {
  width: 160px;
  height: 14px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 7px;
  overflow: hidden;
  margin: 2px 0 10px auto;
}
.barFill {
  height: 100%;
  transition: width 0.1s linear;
}
#growBar { background: linear-gradient(90deg, #81c784, #4caf50); }
#boostBar { background: linear-gradient(90deg, #4fc3f7, #29b6f6); }
#depthBar { background: linear-gradient(90deg, #4fc3f7, #01579b); }

#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  overflow-y: auto;
  background: rgba(0,0,0,0.55);
  color: #fff;
  text-align: center;
  padding: 20px;
  box-sizing: border-box;
}
#overlay > div {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}
#overlay > div[hidden] {
  display: none;
}
#overlay h1 {
  font-size: 40px;
  margin: 0 0 10px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
}
#overlay p {
  font-size: 17px;
  max-width: 560px;
  line-height: 1.6;
  margin: 6px 0;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
#overlay .choose {
  margin-top: 16px;
  font-weight: bold;
}
.btnRow {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}
#overlay .btn {
  padding: 14px 30px;
  font-size: 20px;
  background: #29b6f6;
  border: none;
  border-radius: 8px;
  color: #06202b;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
#overlay .btn:hover {
  background: #4fc3f7;
}
#overlay .btn.default,
#overlay .btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}
/* once the arrows move the focus, only the focused button is ringed */
#overlay > div:focus-within .btn.default:not(:focus-visible) {
  outline: none;
}
#overlay .btn.secondary {
  background: rgba(255,255,255,0.18);
  color: #fff;
}
#overlay .btn.secondary:hover {
  background: rgba(255,255,255,0.3);
}
.graphicsRow {
  align-items: center;
  margin-top: 18px;
  font-size: 15px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
#overlay .btn.toggle {
  padding: 6px 16px;
  font-size: 15px;
  background: rgba(255,255,255,0.18);
  color: #fff;
  box-shadow: none;
}
#overlay .btn.toggle:hover {
  background: rgba(255,255,255,0.3);
}
#overlay .btn.toggle.active {
  background: #29b6f6;
  color: #06202b;
}
.btnRow[hidden] { display: none; }
/* Start-screen records table (shown instead of the description once something is saved) */
#records h2 {
  font-size: 22px;
  margin: 6px 0 8px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
#records table {
  border-collapse: collapse;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
}
#records th, #records td { padding: 7px 14px; }
#records th {
  font-size: 13px;
  font-weight: normal;
  opacity: 0.8;
}
#records tbody tr { border-top: 1px solid rgba(255,255,255,0.18); }
#records td:first-child { text-align: left; font-weight: bold; }
.recordsRow { margin-top: 10px; }
#overlay .recordsRow .btn {
  padding: 6px 16px;
  font-size: 15px;
}
@media (max-width: 520px) {
  #records table { font-size: 14px; }
  #records th, #records td { padding: 5px 6px; }
}
.demoRow { margin-top: 14px; }
#overlay .demoRow .btn {
  padding: 8px 22px;
  font-size: 16px;
}
#banner {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff176;
  font-size: 30px;
  font-weight: bold;
  text-shadow: 0 2px 8px rgba(0,0,0,0.9);
  pointer-events: none;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s;
}

/* ---------- Sea King dialog ---------- */
.kingCard {
  position: relative;
  max-width: 460px;
  padding: 28px 30px 26px;
  border-radius: 20px;
  background: linear-gradient(160deg, #4a148c 0%, #1a237e 55%, #006064 100%);
  border: 2px solid rgba(255, 213, 79, 0.7);
  box-shadow: 0 0 40px rgba(255, 213, 79, 0.35), 0 12px 40px rgba(0,0,0,0.6);
  animation: kingPop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.crown {
  font-size: 64px;
  line-height: 1;
  animation: crownBob 1.6s ease-in-out infinite;
}
#overlay .kingTitle {
  margin: 8px 0 4px;
  font-size: 34px;
  background: linear-gradient(90deg, #fff59d, #ffd54f, #ffb300, #ffd54f, #fff59d);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  animation: shimmer 3s linear infinite;
}
#overlay .kingSub {
  margin: 0 0 16px;
  opacity: 0.85;
}
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.12);
}
.statLabel {
  font-size: 13px;
  opacity: 0.75;
}
.stat b {
  font-size: 26px;
  font-variant-numeric: tabular-nums;
}
.record {
  margin-top: 16px;
  padding: 8px 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffb300, #ffd54f);
  color: #3e2723;
  font-weight: bold;
  font-size: 18px;
  animation: recordPulse 1.2s ease-in-out infinite;
}
.record[hidden], .cheatNote[hidden] { display: none; }
.cheatNote {
  margin-top: 14px;
  font-size: 14px;
  color: #ffcc80;
}
.kingCard .btnRow { margin-top: 20px; }

#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Max-size variant: hotter colors and a stronger pulsing glow */
#kingPanel.epic .kingCard {
  background: linear-gradient(160deg, #b71c1c 0%, #6a1b9a 45%, #0d47a1 100%);
  border-color: #ffd54f;
  animation: kingPop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both, epicGlow 1.6s ease-in-out 0.45s infinite;
}
#kingPanel.epic .crown { font-size: 76px; }

@keyframes epicGlow {
  0%, 100% { box-shadow: 0 0 40px rgba(255, 213, 79, 0.45), 0 12px 40px rgba(0,0,0,0.6); }
  50% { box-shadow: 0 0 80px rgba(255, 213, 79, 0.9), 0 12px 40px rgba(0,0,0,0.6); }
}
@keyframes kingPop {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes crownBob {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-8px) rotate(6deg); }
}
@keyframes shimmer {
  to { background-position: -200% 0; }
}
@keyframes recordPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 rgba(255, 213, 79, 0); }
  50% { transform: scale(1.06); box-shadow: 0 0 22px rgba(255, 213, 79, 0.7); }
}
@media (prefers-reduced-motion: reduce) {
  .kingCard, .crown, #overlay .kingTitle, .record, #kingPanel.epic .kingCard { animation: none; }
}

@media (max-width: 600px), (max-height: 500px) {
  .kingCard { padding: 18px 18px 16px; }
  .crown { font-size: 44px; }
  #overlay .kingTitle { font-size: 26px; }
  .stat b { font-size: 20px; }
  #hud { font-size: 15px; }
  #hud .size { font-size: 20px; }
  #bars { font-size: 12px; }
  .barBg { width: 110px; height: 11px; margin-bottom: 6px; }
  #overlay h1 { font-size: 28px; }
  #overlay p { font-size: 14px; line-height: 1.4; margin: 4px 0; }
  #overlay .btn { padding: 10px 22px; font-size: 17px; }
  #banner { font-size: 22px; top: 70px; }
}

/* the mouse cursor, hidden in fullscreen while it is still (core/cursor.js) */
html.cursor-hidden, html.cursor-hidden * { cursor: none !important; }
