html,body{margin:0;padding:0;width:100%;height:100%;background:#05050f;color:#fff;overflow:hidden}body.dfa-game-page{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Hiragino Sans","Hiragino Kaku Gothic ProN",Meiryo,sans-serif}#dfa-game-root{height:100%;display:flex;flex-direction:column;padding:12px;background:#05050f}#dfa-game-shell{flex:1;min-height:0}#game-container{height:100%}#three-canvas-container{background:#000}button{font:inherit}canvas{outline:none}.dfa-system-error{position:absolute;inset:0;z-index:30;display:flex;align-items:center;justify-content:center;padding:24px;text-align:center;background:rgba(0,0,0,.72);color:#fff}.dfa-system-error__box{max-width:520px;background:rgba(17,24,39,.92);border:1px solid rgba(255,255,255,.14);border-radius:16px;padding:20px 24px;box-shadow:0 12px 40px rgba(0,0,0,.35)}.dfa-system-error__box h2{margin:0 0 10px;font-size:24px;color:#ff5e3a}.dfa-system-error__box p{margin:0 0 8px;line-height:1.7;color:#d1d5db}@media (max-width:767px){html,body{overflow:hidden}#dfa-game-root{padding:8px}}
{
  --dfa-bg: #10131d;
  --dfa-panel: rgba(0, 0, 0, 0.55);
  --dfa-accent: #ff5e3a;
  --dfa-text: #ffffff;
  --dfa-muted: #d6d6d6;
  --dfa-radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  color: var(--dfa-text);
  max-width: 100%;
  margin: 1.5rem auto;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.dfa-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.dfa-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dfa-title {
  font-size: 20px;
  line-height: 1.2;
}

.dfa-subtitle {
  font-size: 12px;
  color: #4b5563;
}

.dfa-subtitle code {
  background: #f3f4f6;
  border-radius: 6px;
  padding: 2px 6px;
}

.dfa-toolbar-btn,
.diff-btn,
.gui-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
}

.dfa-toolbar-btn {
  background: #111827;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1;
}

.dfa-shell {
  position: relative;
  width: 100%;
  background: var(--dfa-bg);
  border-radius: var(--dfa-radius);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  touch-action: none;
}

#game-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 320px;
  background: #000;
}

#three-canvas-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#three-canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.player-hint {
  position: absolute;
  top: 18px;
  left: 18px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--dfa-panel);
  border-left: 4px solid #1976d2;
  backdrop-filter: blur(4px);
  max-width: min(300px, calc(100% - 36px));
}

.player-hint h2 {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.3;
}

.player-hint p {
  margin: 4px 0;
  font-size: 14px;
  color: var(--dfa-muted);
}

.player-hint strong {
  color: #fff;
}

#menu-overlay,
#game-over-overlay,
#countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

#countdown-overlay {
  background: transparent;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.15;
  color: var(--dfa-accent);
  text-shadow: 0 4px 16px rgba(255, 94, 58, 0.35);
}

.subtitle {
  margin: 0;
  font-size: clamp(14px, 2vw, 18px);
  color: #d1d5db;
  max-width: 640px;
}

.dfa-result-subtitle {
  margin-top: -2px;
  margin-bottom: 4px;
}

#countdown-text {
  font-size: clamp(64px, 12vw, 150px);
  color: #fff;
  text-shadow: 0 0 30px var(--dfa-accent);
  animation: dfa-popIn 1s infinite alternate;
}

@keyframes dfa-popIn {
  from { transform: scale(0.85); opacity: 0.85; }
  to { transform: scale(1.15); opacity: 1; }
}

.difficulty-buttons {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.diff-btn {
  min-width: 120px;
  padding: 12px 22px;
  font-size: 17px;
  background: #2196f3;
  box-shadow: 0 8px 20px rgba(33, 150, 243, 0.35);
}

.diff-btn[data-level="easy"] {
  background: #4caf50;
  box-shadow: 0 8px 20px rgba(76, 175, 80, 0.35);
}

.btn-strong {
  background: var(--dfa-accent);
  box-shadow: 0 8px 20px rgba(255, 94, 58, 0.35);
}

#mobile-gui {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
}

.gui-left-area,
.gui-right-area {
  position: absolute;
  bottom: 12px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.gui-left-area {
  left: 12px;
}

.gui-right-area {
  right: 12px;
}

.gui-height-ctrl {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gui-dpad {
  position: relative;
  width: 168px;
  height: 168px;
}

.gui-btn {
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: rgba(17, 24, 39, 0.78);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.gui-btn:active,
.gui-btn.is-active {
  transform: scale(0.96);
}

.gui-height-ctrl .gui-btn,
.gui-flip-btn {
  width: 74px;
  height: 74px;
  border-radius: 18px;
  font-size: 18px;
  display: grid;
  place-items: center;
  line-height: 1.1;
}

.gui-height-ctrl .gui-btn span,
.gui-flip-btn span {
  display: block;
  font-size: 12px;
  font-weight: 600;
}

.gui-flip-btn {
  width: 88px;
  height: 88px;
  background: rgba(255, 94, 58, 0.78);
}

.dpad-up,
.dpad-down,
.dpad-left,
.dpad-right {
  position: absolute;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  font-size: 18px;
}

.dpad-up { top: 0; left: 55px; }
.dpad-down { bottom: 0; left: 55px; }
.dpad-left { left: 0; top: 55px; }
.dpad-right { right: 0; top: 55px; }

.dfa-warning {
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fdba74;
}

#dfa-game-root.is-fullscreen,
.dfa-shell:fullscreen,
.dfa-shell:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border-radius: 0;
}

#dfa-game-shell:fullscreen #game-container,
#dfa-game-shell:-webkit-full-screen #game-container {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
}

@media (max-width: 900px) {
  #game-container {
    min-height: 280px;
  }

  .player-hint {
    max-width: min(260px, calc(100% - 24px));
    top: 12px;
    left: 12px;
    padding: 10px 12px;
  }
}

@media (max-width: 767px) {
  .dfa-toolbar {
    align-items: stretch;
  }

  .dfa-toolbar-btn {
    width: 100%;
  }

  #game-container {
    min-height: 420px;
    aspect-ratio: auto;
    height: min(78vh, 640px);
  }

  .player-hint {
    display: none;
  }

  #mobile-gui {
    display: block;
  }

  #menu-overlay,
  #game-over-overlay,
  #countdown-overlay {
    padding-bottom: 180px;
  }
}

@media (max-width: 480px) {
  #game-container {
    min-height: 360px;
    height: min(72vh, 560px);
  }

  .difficulty-buttons {
    flex-direction: column;
    width: 100%;
    max-width: 280px;
  }

  .diff-btn {
    width: 100%;
  }

  .gui-dpad {
    width: 150px;
    height: 150px;
  }

  .dpad-up,
  .dpad-down,
  .dpad-left,
  .dpad-right {
    width: 52px;
    height: 52px;
  }

  .dpad-up { left: 49px; }
  .dpad-down { left: 49px; }
  .dpad-left { top: 49px; }
  .dpad-right { top: 49px; }

  .gui-height-ctrl .gui-btn,
  .gui-flip-btn {
    width: 66px;
    height: 66px;
  }

  .gui-flip-btn {
    width: 78px;
    height: 78px;
  }
}
