* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; background: #000; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: #fff; }
body { touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

#game-root {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
}

#game-canvas {
  width: 100%; height: 100%;
  touch-action: none;
}
#game-canvas canvas { display: block; margin: 0 auto; }

.overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  transition: opacity 0.3s;
  overflow-y: auto;
  padding: 16px;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.overlay-content { text-align: center; max-width: 80%; max-height: 100%; }
.big-emoji { font-size: 80px; margin-bottom: 20px; }

@media (orientation: portrait) and (max-width: 600px) {
  #orientation-overlay { display: flex !important; opacity: 1 !important; pointer-events: auto !important; }
}

.overlay-content h1 { font-size: 48px; margin-bottom: 16px; letter-spacing: 4px; }
.overlay-content p { font-size: 22px; margin-bottom: 8px; font-family: monospace; }
.overlay-content #gameover-hi { color: #ffd54f; }
.overlay-content #gameover-hi.new::after { content: ' NEW!'; color: #ff5252; font-weight: bold; }

.big-button {
  margin-top: 24px;
  padding: 16px 48px;
  font-size: 22px;
  font-family: monospace;
  background: #ffeb3b;
  color: #212121;
  border: 4px solid #fbc02d;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
}
.big-button:active { transform: scale(0.95); background: #fbc02d; }

.title-main { font-size: 56px; letter-spacing: 6px; color: #ffeb3b; text-shadow: 4px 4px 0 #c62828; margin-bottom: 24px; }
.tutorial-reset { margin-top: 32px; font-size: 12px; opacity: 0.5; }
.tutorial-reset a { color: #fff; }

#tutorial-overlay h2 { font-size: 36px; margin-bottom: 32px; letter-spacing: 4px; }
.tutorial-row { display: flex; align-items: center; gap: 24px; margin-bottom: 32px; }
.swipe-indicator { width: 60px; height: 80px; position: relative; }
.swipe-indicator .finger { font-size: 32px; color: #fff; position: absolute; left: 18px; }
.swipe-indicator .trail {
  position: absolute; left: 28px; width: 4px; background: rgba(255,255,255,0.4); border-radius: 2px;
}
.swipe-up .finger { animation: swipe-up-finger 1.2s ease-in-out infinite; top: 40px; }
.swipe-up .trail { top: 0; height: 80px; animation: swipe-up-trail 1.2s ease-in-out infinite; }
.swipe-down .finger { animation: swipe-down-finger 1.2s ease-in-out infinite; top: 0; }
.swipe-down .trail { top: 0; height: 80px; animation: swipe-down-trail 1.2s ease-in-out infinite; }
@keyframes swipe-up-finger { 0% { top: 40px; opacity: 1; } 80% { top: 0; opacity: 0.3; } 100% { top: 0; opacity: 0; } }
@keyframes swipe-up-trail { 0% { transform: scaleY(0); transform-origin: bottom; } 80% { transform: scaleY(1); transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }
@keyframes swipe-down-finger { 0% { top: 0; opacity: 1; } 80% { top: 40px; opacity: 0.3; } 100% { top: 40px; opacity: 0; } }
@keyframes swipe-down-trail { 0% { transform: scaleY(0); transform-origin: top; } 80% { transform: scaleY(1); transform-origin: top; } 100% { transform: scaleY(0); transform-origin: top; } }
.tutorial-action { font-size: 20px; }

/* Tutorial variants: body gets `is-touch` class on touch devices, otherwise keyboard variant shows */
.touch-only, .kbd-only { display: none; }
body.is-touch .touch-only { display: flex; }
body:not(.is-touch) .kbd-only { display: flex; }

.kbd-row { display: flex; align-items: center; gap: 10px; width: 80px; justify-content: center; }
.kbd-key {
  display: inline-block;
  min-width: 36px;
  padding: 6px 10px;
  border: 3px solid #fff;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  font-family: monospace;
  font-size: 18px;
  text-align: center;
  box-shadow: 0 3px 0 rgba(255, 255, 255, 0.4);
  font-weight: bold;
}
.kbd-key.kbd-wide { min-width: 64px; }
.kbd-or { font-size: 14px; opacity: 0.7; }

/* Landscape mobile: compact tutorial so the Start button isn't pushed under the browser chrome */
@media (orientation: landscape) and (max-height: 500px) {
  #tutorial-overlay h2 { font-size: 22px; margin-bottom: 12px; letter-spacing: 2px; }
  #tutorial-overlay .tutorial-row { gap: 14px; margin-bottom: 12px; }
  #tutorial-overlay .swipe-indicator { width: 40px; height: 48px; }
  #tutorial-overlay .swipe-indicator .finger { font-size: 22px; left: 12px; }
  #tutorial-overlay .swipe-up .trail,
  #tutorial-overlay .swipe-down .trail { height: 48px; left: 19px; }
  #tutorial-overlay .tutorial-action { font-size: 16px; }
  #tutorial-overlay .big-button { margin-top: 10px; padding: 10px 28px; font-size: 18px; }
  .title-main { font-size: 36px; margin-bottom: 12px; letter-spacing: 4px; }
  #title-overlay .big-button { margin-top: 12px; padding: 12px 32px; font-size: 20px; }
  .tutorial-reset { margin-top: 16px; }
}
