* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  background: #dff6ff;
  color: #17324d;
}
#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  min-height: 64px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(90deg, #084c8d, #0aa1dd);
  color: white;
  box-shadow: 0 4px 18px rgba(0,0,0,.18);
  z-index: 20;
}
.brand {
  font-size: clamp(20px, 4vw, 32px);
  font-weight: 900;
  line-height: 1;
}
.small {
  opacity: .94;
  font-size: 13px;
  margin-top: 4px;
}
.hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.pill {
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px;
  padding: 8px 11px;
  font-size: 14px;
}
.gameWrap {
  flex: 1;
  position: relative;
  place-items: center;
  padding: 0;
  background: radial-gradient(circle at 50% 10%, #fff3b0, #bcefff 45%, #79d874 46%, #39ab43);
}
#scene3d {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
  background: #98deff;
}
#scene3d canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.panel {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 580px);
  background: rgba(255,255,255,.97);
  border-radius: 28px;
  padding: 22px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
  display: none;
  border: 4px solid rgba(8,76,141,.12);
  z-index: 25;
}
.panel.show { display: block; }
.panel h1 { margin: 0 0 10px; font-size: clamp(28px, 6vw, 46px); }
.panel h2 { font-size: clamp(34px, 8vw, 58px); margin: 14px 0; color: #0a5595; }
.panel p { font-size: 18px; line-height: 1.35; }
.loadingText { font-weight: 900; color: #0a5595; min-height: 24px; }
.bigBtn, .ghostBtn, .levelBtn {
  border: 0;
  border-radius: 18px;
  padding: 15px 22px;
  font-weight: 900;
  font-size: 19px;
  cursor: pointer;
  margin: 6px;
  box-shadow: 0 6px 0 rgba(0,0,0,.16);
}
.bigBtn[disabled] {
  opacity: .55;
  cursor: wait;
}
.bigBtn { background: #ffd23f; color: #473200; }
.ghostBtn { background: #e9f3ff; color: #0a5595; }
.levelChooser {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 16px 0;
}
.levelBtn {
  margin: 0;
  padding: 12px 4px;
  background: #e9f3ff;
  color: #0a5595;
  font-size: 16px;
}
.levelBtn.active { background: #ffd23f; color: #473200; outline: 3px solid #ff9f1c; }
.levelBtn.locked { opacity: .38; filter: grayscale(1); }
.stationBadge {
  display: inline-block;
  background: #ffeb99;
  border-radius: 999px;
  padding: 9px 14px;
  font-weight: 900;
  color: #5b3b00;
}
.answerGrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.answerGrid button {
  border: 0;
  border-radius: 18px;
  padding: 18px;
  font-size: 30px;
  font-weight: 900;
  background: #e7f7ff;
  color: #084c8d;
  box-shadow: 0 6px 0 rgba(0,0,0,.14);
  cursor: pointer;
}
.feedback {
  min-height: 28px;
  font-weight: 900;
}
.mobileControls {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: row;
  gap: 12px;
  z-index: 15;
}
.mobileControls button {
  width: 96px;
  height: 96px;
  border-radius: 28px;
  border: 0;
  background: rgba(255,255,255,.96);
  font-size: 38px;
  box-shadow: 0 10px 22px rgba(0,0,0,.24);
  touch-action: manipulation;
}
.guideBox {
  position: absolute;
  left: 20px;
  bottom: 18px;
  max-width: min(50vw, 420px);
  padding: 12px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,.88);
  color: #17324d;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(0,0,0,.16);
  z-index: 12;
}
.footer {
  display: none;
  min-height: 34px;
  place-items: center;
  text-align: center;
  padding: 6px 10px;
  background: #17324d;
  color: #fff;
  font-size: 13px;
}
@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    min-height: 106px;
  }
  .hud { justify-content: flex-start; }
  #scene3d {
    width: 100%;
    height: calc(100vh - 188px);
    max-height: calc(100vh - 188px);
  }
  .panel { padding: 18px; width: min(94vw, 560px); }
  .levelChooser { grid-template-columns: repeat(4, 1fr); }
  .guideBox { max-width: calc(100vw - 130px); font-size: 14px; }
  .footer { display: none; }
}

.debugPanel {
  position: absolute;
  right: 18px;
  top: 18px;
  left: auto;
  width: min(420px, calc(100vw - 36px));
  max-height: 38vh;
  background: rgba(7, 20, 35, .88);
  color: #d8f7ff;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(0,0,0,.28);
  z-index: 40;
  overflow: hidden;
  font-size: 12px;
}
.debugHead {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255,255,255,.1);
}
.debugHead b { margin-right: auto; }
.debugHead button {
  border: 0;
  border-radius: 10px;
  padding: 6px 9px;
  font-weight: 800;
  cursor: pointer;
  color: #07304d;
  background: #aeefff;
}
#debugLog {
  margin: 0;
  padding: 10px;
  max-height: calc(38vh - 40px);
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.35;
  font-family: Consolas, Monaco, monospace;
}
@media (max-width: 860px) {
  .debugPanel {
    top: auto;
    bottom: 104px;
    left: 10px;
    right: 10px;
    width: auto;
    max-height: 30vh;
  }
  #debugLog { max-height: calc(30vh - 40px); }
}


.missionHud {
  position: absolute;
  left: 20px;
  top: 18px;
  width: min(360px, calc(100vw - 40px));
  padding: 14px 16px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(255,255,255,.96), rgba(255,247,188,.93));
  color: #17324d;
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
  z-index: 18;
  border: 2px solid rgba(255,210,63,.8);
}
.missionTitle { font-weight: 950; font-size: 18px; margin-bottom: 5px; color: #084c8d; }
#missionText { font-weight: 800; line-height: 1.25; }
.miniStats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.miniStats span {
  background: rgba(8,76,141,.1);
  border-radius: 999px;
  padding: 7px 10px;
  font-weight: 900;
}
.noticeToast {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  opacity: 0;
  pointer-events: none;
  z-index: 45;
  padding: 14px 22px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd23f, #ff8c42);
  color: #3c2600;
  font-size: 22px;
  font-weight: 950;
  box-shadow: 0 12px 28px rgba(0,0,0,.25);
  transition: opacity .25s ease, transform .25s ease;
}
.noticeToast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.topbar { background: linear-gradient(90deg, #133c8b, #0aa1dd, #23c16b); }
.pill { font-weight: 800; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.panel { border-color: rgba(255,210,63,.55); }
.bigBtn { background: linear-gradient(180deg, #ffe66d, #ffba08); }
.answerGrid button { background: linear-gradient(180deg, #ffffff, #caefff); }

@media (max-width: 860px) {
  .missionHud {
    top: 10px;
    left: 10px;
    width: min(330px, calc(100vw - 20px));
    padding: 10px 12px;
    font-size: 13px;
  }
  .noticeToast { font-size: 17px; top: 12px; }
}


.gameControlBar {
  position: absolute;
  left: 18px;
  top: 18px;
  display: flex;
  gap: 12px;
  z-index: 35;
}
.roundControl {
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  min-height: 58px;
  font-size: 18px;
  font-weight: 900;
  color: #07304d;
  background: rgba(255,255,255,.95);
  box-shadow: 0 8px 20px rgba(0,0,0,.22);
  touch-action: manipulation;
}
.roundControl:active,
.mobileControls button:active,
.bigBtn:active,
.ghostBtn:active,
.answerGrid button:active {
  transform: translateY(2px) scale(.98);
}

@media (max-width: 860px) {
  .mobileControls {
    right: 14px;
    bottom: 14px;
    gap: 16px;
  }
  .mobileControls button {
    width: 104px;
    height: 104px;
    font-size: 42px;
  }
  .gameControlBar {
    left: 12px;
    top: 12px;
    gap: 10px;
  }
  .roundControl {
    min-height: 64px;
    padding: 15px 18px;
    font-size: 18px;
  }
  .guideBox {
    display: none;
  }
}

:fullscreen #app,
:-webkit-full-screen #app {
  width: 100vw;
  height: 100vh;
}


.devCredit {
  display: inline-block;
  margin: 2px 0 8px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(8,76,141,.1);
  color: #084c8d;
  font-weight: 950;
  letter-spacing: .2px;
}
.cornerCredit {
  position: absolute;
  left: 18px;
  bottom: 10px;
  z-index: 20;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.82);
  color: #07304d;
  font-weight: 850;
  box-shadow: 0 8px 18px rgba(0,0,0,.16);
}
.boostPanel {
  position: absolute;
  left: 20px;
  top: 142px;
  width: min(360px, calc(100vw - 40px));
  padding: 12px;
  border-radius: 22px;
  background: rgba(255,255,255,.94);
  color: #17324d;
  z-index: 19;
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
  border: 2px solid rgba(255,186,8,.8);
}
.boostTop {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
  font-weight: 950;
  margin-bottom: 8px;
}
.boostTrack {
  height: 18px;
  border-radius: 999px;
  background: rgba(8,76,141,.12);
  overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(0,0,0,.16);
}
.boostFill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #00c2ff, #23c16b, #ffd23f);
  transition: width .25s ease;
}
.boostBtn {
  width: 100%;
  margin-top: 10px;
  border: 0;
  border-radius: 18px;
  min-height: 58px;
  font-size: 20px;
  font-weight: 950;
  color: #3c2600;
  background: linear-gradient(180deg, #ffe66d, #ffba08);
  box-shadow: 0 7px 0 rgba(0,0,0,.16);
  touch-action: manipulation;
}
.boostBtn:disabled {
  opacity: .55;
  filter: grayscale(.3);
}
@media (max-width: 860px) {
  .topbar { min-height: 86px; padding: 7px 10px; }
  .brand { font-size: 22px; }
  .small { font-size: 12px; }
  .hud { gap: 5px; }
  .pill { padding: 6px 8px; font-size: 12px; }
  #scene3d { height: 100%; max-height: none; }
  .boostPanel { top: 118px; left: 10px; width: min(310px, calc(100vw - 20px)); padding: 10px; }
  .boostBtn { min-height: 66px; font-size: 21px; }
  .cornerCredit { left: 10px; bottom: 6px; font-size: 12px; }
  .panel { max-height: 92vh; overflow: auto; }
}


/* FINAL UI CLEANUP */
.debugPanel { display: none !important; }
.gameWrap { padding: 0; }
#scene3d {
  width: 100vw;
  height: calc(100vh - 78px);
  max-width: none;
  max-height: none;
  border-radius: 0;
  box-shadow: none;
}
.gameControlBar {
  left: auto !important;
  right: 14px;
  top: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: min(46vw, 360px);
  gap: 10px;
}
.roundControl {
  min-height: 56px;
  padding: 13px 17px;
  font-size: 18px;
  border-radius: 999px;
}
.missionHud {
  left: 14px;
  top: 14px;
  width: min(340px, calc(100vw - 420px));
  min-width: 250px;
  padding: 12px 14px;
}
.boostPanel {
  left: 14px;
  top: 132px;
  width: min(340px, calc(100vw - 420px));
  min-width: 250px;
  padding: 10px 12px 12px;
}
.boostTop { font-size: 17px; }
.boostTrack { height: 17px; }
.boostBtn { min-height: 54px; font-size: 20px; }
.mobileControls {
  right: 18px;
  bottom: 18px;
  gap: 18px;
}
.mobileControls button {
  width: 112px;
  height: 112px;
  font-size: 46px;
  border-radius: 32px;
}
.cornerCredit { left: 14px; bottom: 10px; }
@media (max-width: 860px) {
  .topbar { display: none; }
  #scene3d { height: 100vh; }
  .gameControlBar {
    top: 8px;
    right: 8px;
    max-width: calc(100vw - 16px);
    gap: 8px;
  }
  .roundControl {
    min-height: 50px;
    padding: 11px 13px;
    font-size: 16px;
  }
  .missionHud {
    left: 8px;
    top: 70px;
    width: min(330px, calc(100vw - 16px));
    min-width: 0;
    padding: 10px 12px;
  }
  .missionTitle { font-size: 16px; }
  #missionText { font-size: 14px; }
  .miniStats { margin-top: 7px; gap: 6px; }
  .miniStats span { padding: 6px 8px; font-size: 13px; }
  .boostPanel {
    left: 8px;
    top: 184px;
    width: min(330px, calc(100vw - 16px));
    min-width: 0;
    padding: 9px 10px 10px;
  }
  .boostTop { font-size: 16px; margin-bottom: 6px; }
  .boostTrack { height: 16px; }
  .boostBtn { min-height: 54px; font-size: 19px; margin-top: 8px; }
  .mobileControls {
    right: 10px;
    bottom: 10px;
    gap: 14px;
  }
  .mobileControls button {
    width: 104px;
    height: 104px;
    font-size: 42px;
  }
  .noticeToast { top: 8px; font-size: 16px; padding: 10px 16px; max-width: calc(100vw - 120px); text-align: center; }
  .cornerCredit { left: 8px; bottom: 6px; font-size: 12px; }
  .panel { max-height: 94vh; overflow: auto; width: min(94vw, 580px); }
}
@media (max-width: 420px) {
  .missionHud { top: 64px; width: calc(100vw - 16px); }
  .boostPanel { top: 188px; width: calc(100vw - 16px); }
  .mobileControls button { width: 88px; height: 88px; font-size: 36px; }
}
