* {
  box-sizing: border-box;
}

:root {
  --ink: #1d1b14;
  --paper: #fff0cf;
  --paper-strong: #ffe4aa;
  --line: #c89a4a;
  --blue: #149de0;
  --grass: #56b71f;
  --leaf: #23821d;
  --gold: #ffca28;
  --danger: #f4362f;
  --shadow: rgba(48, 31, 12, 0.26);
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #28a8ed;
  color: var(--ink);
  font-family: "Trebuchet MS", Verdana, sans-serif;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#game,
#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#scene {
  display: block;
  touch-action: none;
}

.status-panel,
.help-panel,
.menu-panel {
  border: 2px solid rgba(82, 55, 22, 0.3);
  background:
    linear-gradient(180deg, rgba(255, 246, 220, 0.96), rgba(255, 232, 181, 0.94)),
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.7), transparent 42%);
  box-shadow: 0 12px 28px var(--shadow), inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.status-panel {
  position: fixed;
  z-index: 5;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  width: 310px;
  padding: 14px 16px 12px;
  border-radius: 8px;
  text-transform: uppercase;
}

.status-panel h1,
.help-panel h2,
.menu-panel h2 {
  margin: 0;
  color: #101010;
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0;
}

.stat-grid {
  display: grid;
  gap: 9px;
  margin-top: 14px;
  font-size: 16px;
  font-weight: 900;
}

.stat-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 12px;
  align-items: center;
}

.stat-grid strong {
  min-width: 86px;
  text-align: right;
  font-size: 18px;
}

.stat-icon {
  width: 22px;
  height: 22px;
  display: inline-block;
  position: relative;
}

.stat-icon.star,
.tiny-star {
  clip-path: polygon(50% 0%, 62% 34%, 98% 35%, 69% 56%, 80% 92%, 50% 70%, 20% 92%, 31% 56%, 2% 35%, 38% 34%);
  background: linear-gradient(135deg, #fff66d, var(--gold) 62%, #e68600);
  border: 1px solid #d18a00;
}

.stat-icon.pin {
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: linear-gradient(135deg, #a8ff6e, #25aa23);
  border: 2px solid #138718;
}

.stat-icon.pin::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: #fff7d7;
}

.stat-icon.fish {
  width: 24px;
  border-radius: 60% 45% 45% 60%;
  background: linear-gradient(135deg, #6be7ff, #0776cc);
}

.stat-icon.fish::before {
  content: "";
  position: absolute;
  right: -7px;
  top: 4px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 9px solid #0776cc;
}

.stat-icon.speed {
  border: 3px solid #1a73c9;
  border-bottom-color: transparent;
  border-radius: 50%;
}

.stat-icon.speed::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 9px;
  width: 9px;
  height: 3px;
  transform-origin: left center;
  transform: rotate(-35deg);
  background: #1a73c9;
}

.stat-icon.life,
.life-dot {
  border-radius: 50% 50% 46% 46%;
  background: linear-gradient(135deg, #ff6a5d, var(--danger));
  box-shadow: inset 0 -3px 0 rgba(104, 0, 0, 0.2);
}

.lives {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.life-dot {
  width: 20px;
  height: 20px;
  display: inline-block;
}

.life-dot.empty {
  filter: grayscale(1);
  opacity: 0.28;
}

.biome-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.biome-badge {
  padding: 8px 16px;
  border-radius: 6px;
  color: #fff;
  background: linear-gradient(180deg, #61d846, #1f9a30);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3), 0 3px 0 #136c22;
  font-size: 15px;
  font-weight: 950;
}

#combo {
  color: #2071cc;
  font-size: 22px;
}

.help-panel {
  position: fixed;
  z-index: 5;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  width: 270px;
  padding: 15px 18px;
  border-radius: 8px;
  text-transform: uppercase;
}

.key-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 10px;
  margin-top: 15px;
  padding-bottom: 14px;
  border-bottom: 2px solid rgba(64, 44, 15, 0.14);
  font-size: 14px;
}

.key-grid span {
  font-weight: 950;
}

.key-grid strong {
  font-size: 13px;
}

.help-panel p {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 0;
  font-weight: 950;
  font-size: 15px;
}

.tiny-star {
  width: 26px;
  height: 26px;
  display: inline-block;
  flex: 0 0 auto;
}

.round-btn {
  position: fixed;
  z-index: 8;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 239, 190, 0.92);
  box-shadow: 0 10px 22px var(--shadow), inset 0 0 0 2px rgba(255, 255, 255, 0.55);
}

.pause-btn {
  right: max(18px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.pause-btn span {
  width: 8px;
  height: 25px;
  border-radius: 2px;
  background: #24180a;
}

.camera-btn {
  right: max(88px, calc(env(safe-area-inset-right) + 88px));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  color: #24180a;
  font-size: 13px;
  font-weight: 950;
}

.speedometer {
  position: fixed;
  z-index: 6;
  left: max(22px, env(safe-area-inset-left));
  bottom: max(22px, env(safe-area-inset-bottom));
  width: 112px;
  height: 112px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 50%, rgba(19, 26, 28, 0.98) 0 48%, transparent 49%),
    conic-gradient(from -135deg, #28df31 var(--speed-deg, 0deg), #2d3438 0 270deg, transparent 0);
  border: 3px solid rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 26px rgba(15, 10, 5, 0.24), inset 0 0 0 5px rgba(13, 18, 20, 0.9);
}

.speedometer::after {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.24);
  pointer-events: none;
}

.speedometer strong {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 18px;
  font-weight: 950;
  text-align: center;
  text-shadow: 0 2px 0 #000;
}

.speed-dial span {
  display: none;
}

.touch-controls {
  position: fixed;
  z-index: 9;
  left: 0;
  right: 0;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 max(14px, env(safe-area-inset-left)) 0 max(14px, env(safe-area-inset-right));
  pointer-events: none;
}

.touch-left,
.touch-right {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.touch-controls button {
  width: 58px;
  height: 58px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  color: #fff;
  background: rgba(20, 34, 34, 0.72);
  font-size: 21px;
  font-weight: 950;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.24);
}

.touch-controls button.active {
  transform: translateY(2px);
  background: rgba(21, 146, 47, 0.86);
}

.jump-touch {
  background: rgba(240, 166, 16, 0.88) !important;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 28, 21, 0.28);
  backdrop-filter: blur(3px);
}

.overlay.hidden {
  display: none;
}

.menu-panel {
  width: min(420px, calc(100vw - 32px));
  padding: 26px;
  border-radius: 8px;
  text-align: center;
}

.menu-panel h2 {
  font-size: 42px;
  text-transform: uppercase;
}

.menu-panel p {
  margin: 16px 0 22px;
  color: #443319;
  font-weight: 800;
  line-height: 1.45;
}

.menu-panel button {
  width: 100%;
  min-height: 54px;
  border-radius: 8px;
  color: #221300;
  background: linear-gradient(180deg, #fff071, #f0a918);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), 0 8px 0 #b36a00;
  font-size: 22px;
  font-weight: 950;
  text-transform: uppercase;
}

.results {
  display: grid;
  gap: 10px;
  margin: 20px 0 24px;
}

.results div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.48);
  font-weight: 950;
  text-transform: uppercase;
}

@media (max-width: 860px), (pointer: coarse) {
  .help-panel {
    display: none;
  }

  .touch-controls {
    display: flex;
  }

  .pause-btn {
    width: 44px;
    height: 44px;
    right: max(10px, env(safe-area-inset-right));
    top: max(10px, env(safe-area-inset-top));
    bottom: auto;
  }

  .camera-btn {
    width: 44px;
    height: 44px;
    right: max(10px, env(safe-area-inset-right));
    top: calc(max(10px, env(safe-area-inset-top)) + 54px);
    bottom: auto;
    font-size: 10px;
  }

  .pause-btn span {
    width: 6px;
    height: 20px;
  }

  .speedometer {
    left: max(14px, env(safe-area-inset-left));
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 72px);
    width: 76px;
    height: 76px;
    border-width: 2px;
  }

  .speedometer::after {
    inset: 9px;
  }

  .speedometer strong {
    font-size: 13px;
  }
}

@media (max-width: 680px) {
  .status-panel {
    top: max(8px, env(safe-area-inset-top));
    left: 8px;
    right: 62px;
    width: auto;
    padding: 9px 10px;
  }

  .status-panel h1 {
    font-size: 15px;
  }

  .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 8px;
    font-size: 10px;
  }

  .stat-row {
    grid-template-columns: 17px minmax(0, auto);
    gap: 5px;
    min-width: 0;
  }

  .stat-row > span:not(.stat-icon) {
    display: none;
  }

  .stat-grid strong {
    min-width: 0;
    font-size: 11px;
    text-align: left;
    white-space: nowrap;
  }

  .stat-icon {
    width: 15px;
    height: 15px;
  }

  .stat-icon.fish {
    width: 17px;
  }

  .stat-icon.fish::before {
    right: -5px;
    top: 3px;
    border-top-width: 5px;
    border-bottom-width: 5px;
    border-left-width: 6px;
  }

  .life-dot {
    width: 12px;
    height: 12px;
  }

  .biome-row {
    margin-top: 8px;
  }

  .biome-badge {
    padding: 5px 9px;
    font-size: 10px;
  }

  #combo {
    font-size: 13px;
  }

  .touch-controls button {
    width: 52px;
    height: 52px;
    font-size: 18px;
  }

  .touch-left,
  .touch-right {
    gap: 8px;
  }

  .menu-panel {
    padding: 20px;
  }

  .menu-panel h2 {
    font-size: 30px;
  }
}
