:root {
  --bg: #0b0d14;
  --btn: #12141d;
  --line: #c9ccd6;
  --text: #eef0f6;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text);
  overflow: hidden; overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  font-family: -apple-system, "Helvetica Neue", Arial, sans-serif;
}
#app {
  height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#top { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 10px; }
#stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 58dvh;
  margin: 0 auto; background: #000; overflow: hidden;
}
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#stage.retro #gl { image-rendering: pixelated; }
#title {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10,10,20,0.15), rgba(5,5,10,0.75));
  cursor: pointer;
}
#title .logo {
  font: italic 900 clamp(30px, 10vw, 64px) Georgia, "Times New Roman", serif; letter-spacing: 0.06em;
  color: #ffe2a8; text-shadow: 0 0 18px #ff8a2a, 0 3px 0 #5a2a10, 0 5px 12px #000;
}
#title .sub { margin-top: 6px; font-size: 13px; color: #d8c8b0; letter-spacing: 0.12em; text-transform: uppercase; }
#title .tap { margin-top: 26px; font-weight: 700; letter-spacing: 0.2em; animation: blink 1.2s infinite; }
#title #err { margin-top: 14px; color: #ff9a8a; font-size: 12px; max-width: 80%; text-align: center; }
@keyframes blink { 50% { opacity: 0.25; } }

button {
  font: 800 13px -apple-system, "Helvetica Neue", Arial, sans-serif; letter-spacing: 0.04em;
  color: var(--text); background: var(--btn); border: 2px solid var(--line); border-radius: 12px;
  touch-action: manipulation; cursor: pointer;
}
button:active, button.on { background: #2a3a7a; border-color: #fff; }
button.small { padding: 8px 14px; font-size: 12px; border-radius: 10px; }
#pad {
  flex: 1; display: flex; align-items: flex-end; justify-content: flex-end; gap: 10px;
  padding: 10px 10px 14px; min-height: 0;
}
#lcol { display: flex; flex-direction: column; gap: 10px; margin-bottom: 90px; }
#lcol button { width: 66px; }
#stick {
  position: relative; width: min(42vw, 170px); aspect-ratio: 1; border-radius: 50%;
  border: 2px solid #c9ccd6; margin-bottom: 40px; touch-action: none;
}
#knob {
  position: absolute; left: 50%; top: 50%; width: 42%; height: 42%; border-radius: 50%;
  background: #a9a39c; transform: translate(-50%, -50%); pointer-events: none;
}
#rgrid { display: grid; grid-template-columns: repeat(2, minmax(62px, 21vw)); gap: 8px; }
#rgrid button { height: min(11vw, 52px); }
#rgrid .wide { grid-column: span 2; height: min(13vw, 58px); font-size: 16px; }
#rgrid .atk { background: #3a1610; border-color: #c46a4a; }
#rgrid .atk:active { background: #7a2a1a; }
#rgrid .ok { background: #1c2650; }

@media (orientation: landscape) and (max-height: 560px) {
  #app { display: grid; grid-template-columns: 1fr auto 1fr; grid-template-rows: auto 1fr; align-items: center; }
  #top { grid-column: 1 / 4; grid-row: 1; position: absolute; right: 0; top: 0; z-index: 2; }
  #stage { grid-column: 2; grid-row: 1 / 3; height: 100dvh; max-height: none; width: auto; }
  #pad { display: contents; }
  #lcol { grid-column: 1; grid-row: 2; flex-direction: row; justify-self: center; margin: 0; align-self: start; }
  #stick { grid-column: 1; grid-row: 2; justify-self: center; align-self: end; margin-bottom: 18px; width: min(22vw, 160px); }
  #rgrid { grid-column: 3; grid-row: 2; justify-self: center; align-self: end; margin-bottom: 12px; grid-template-columns: repeat(2, minmax(56px, 10vw)); }
  #rgrid button { height: min(9vh, 44px); }
}

button.hint, #stick.hint {
  animation: hintpulse 0.9s ease-in-out infinite;
  border-color: #ffe070;
}
@keyframes hintpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 224, 112, 0.0); }
  50% { box-shadow: 0 0 14px 4px rgba(255, 224, 112, 0.85); }
}
