:root {
  color: #fff8e3;
  background: #203a2b;
  font-family: system-ui, sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; }
.game { position: relative; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; }
#field { display: block; width: 100%; height: 100%; touch-action: none; }
#flight-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hud {
  position: absolute; inset: 0 0 auto; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; padding: 14px 22px;
  background: #203a2b; border-bottom: 3px solid #f7c957; z-index: 1;
}
.brand { font-size: 18px; font-family: Georgia, serif; }
.brand span { color: #f7c957; margin-right: 4px; }
.stats { display: flex; gap: 28px; text-align: center; }
.stats div { min-width: 54px; }
.stats small, #kicker { color: #f7c957; font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.stats strong { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
button {
  cursor: pointer; padding: 10px 16px; font: inherit; font-weight: 750;
  color: #203a2b; background: #f7c957; border: 0; border-radius: 8px; min-height: 44px;
}
button:hover { background: #ffda79; }
button:focus-visible { outline: 3px solid white; outline-offset: 4px; }
#restart { background: #345241; border: 1px solid #698373; color: #fff8e3; }
.guidance {
  position: absolute; inset: auto 12px 14px; display: grid;
  justify-items: center; gap: 6px; text-align: center; pointer-events: none;
}
#ability-chip {
  padding: 6px 12px; border-radius: 8px; background: #f7c957; color: #203a2b;
  line-height: 1.25; font-size: 14px;
}
#ability-cue:not(:empty) { display: block; font-size: 12px; }
#hint {
  margin: 0;
  padding: 9px 15px; border-radius: 8px; background: #203a2b; font-size: 13px;
  pointer-events: none;
}
.overlay {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center;
  overflow: auto; padding: 16px; background: #172e2475 center / cover;
}
.overlay[hidden] { display: none; }
.panel {
  width: min(100%, 540px); text-align: center; padding: 25px 22px 30px;
  background: #203a2b; border: 2px solid #789186; border-radius: 20px;
  box-shadow: 0 18px 50px #0d271b66;
}
.portraits canvas { max-width: 100%; height: auto; }
#kicker { margin: 5px 0 12px; }
h1 { font: bold clamp(34px, 8vw, 66px)/.94 Georgia, serif; margin: 0; letter-spacing: -.045em; }
h1 em { font-size: .52em; color: #f7c957; }
#summary { margin: 18px 0 22px; color: #e3edde; }
#action span { margin-left: 12px; }
@media (max-width: 600px) {
  .hud { padding: 8px 10px; gap: 8px; }
  .brand b, #restart b { display: none; }
  .stats { gap: 7px; }
  .stats div { min-width: 40px; }
  .stats small { font-size: 9px; }
  #restart { padding: 6px; min-width: 44px; }
}
.game { overscroll-behavior: none; }
@media (max-width: 350px) {
  .brand { font-size: 0; }
  .brand span { font-size: 20px; margin: 0; }
}
@media (max-height: 430px) and (orientation: landscape) {
  .portraits canvas { max-height: 64px; width: auto; }
  .panel { padding: 12px 18px; }
  h1 { font-size: clamp(30px, 10vh, 48px); }
  #summary { margin: 10px 0 12px; }
}
.hud-actions { display: flex; gap: 6px; }
#level-select { background: #345241; border: 1px solid #698373; color: #fff8e3; }
#level-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(65px, 1fr));
  gap: 7px; margin: 20px 0;
}
#level-grid[hidden] { display: none; }
#level-grid button { display: grid; justify-items: center; padding: 5px; }
#level-grid span { font-size: 12px; }
#level-grid button:disabled { cursor: default; background: #345241; color: #cbdbca; }
#browse { margin-left: 6px; }
@media (max-width: 600px) {
  #level-select { padding: 6px; }
}
#story { align-items: safe center; }
#story-image {
  display: block; width: 100%; max-height: 42dvh; object-fit: contain;
  border-radius: 12px; margin-bottom: 16px;
}
#story-image[hidden] { display: none; }
#story-title { margin: 0; font: bold clamp(24px, 6vw, 40px)/1.05 Georgia, serif; }
#story-text { margin: 14px 0 20px; color: #e3edde; line-height: 1.5; }
.story-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
#story-hear, #story-skip { background: #345241; border: 1px solid #698373; color: #fff8e3; }
#story-hear:hover, #story-skip:hover { background: #426550; }

#result-rating { position: relative; margin-top: 12px; color: #ffda73; font-size: 28px; }
#kernels { position: absolute; inset: 0; pointer-events: none; }
#kernels i {
  position: absolute; left: 50%; top: 50%; width: 9px; height: 6px;
  border-radius: 65% 40% 55% 35%; background: #f7c957;
  animation: scatter-kernel .85s ease-out both;
}
@keyframes scatter-kernel {
  0% { opacity: 0; transform: scale(.5); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(160deg); }
}
@media (prefers-reduced-motion: reduce) {
  #kernels i { animation: none; transform: translate(var(--dx), var(--dy)); }
}
