/* =========================================================
   MATCHSTICK TALES — Full-Screen iOS Landscape Layout & HUD
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Silkscreen:wght@400;700&display=swap');

:root {
  --glass-bg: rgba(14, 16, 24, 0.62);
  --glass-border: rgba(255, 255, 255, 0.18);
  --touch-bg: rgba(16, 18, 28, 0.42);
  --touch-active: rgba(255, 209, 102, 0.48);
  --accent-red: #d93829;
  --accent-gold: #ffd166;
  --font-px: 'Press Start 2P', 'Courier New', monospace;
  --font-ui: 'Silkscreen', 'Courier New', monospace;

  /* iOS Safe Area Insets */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0c0d12;
  font-family: var(--font-ui);
  color: #f8fafc;
  overscroll-behavior: none;
  touch-action: none;
}

/* Full-screen Edge-to-Edge Viewport */
.game-viewport {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  background: #0c0d12;
  overflow: hidden;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.screen-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.32);
  z-index: 2;
}

/* =========================================================
   Top Floating iOS HUD
   ========================================================= */
.ios-hud-top {
  position: absolute;
  top: calc(10px + var(--sat));
  left: calc(12px + var(--sal));
  right: calc(12px + var(--sar));
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.hud-left, .hud-right {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  pointer-events: auto;
}

/* Compact Corner Dummy-Cam Widget */
.dummy-cam-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid var(--glass-border);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.08s ease;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.dummy-cam-widget:active {
  transform: scale(0.93);
}

.dummy-cam-widget.poked {
  animation: camShake 0.28s linear;
}

@keyframes camShake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-3px, 2px) rotate(-4deg); }
  50% { transform: translate(3px, -2px) rotate(4deg); }
  75% { transform: translate(-2px, -1px) rotate(-2deg); }
}

.dummy-cam-frame {
  width: 56px;
  height: 56px;
  background: #f2e4b7;
  border: 2px solid #161822;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#faceCanvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.dummy-cam-mood {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 9px;
  color: #f8fafc;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 0 #090a10;
  white-space: nowrap;
}

/* HUD Pills */
.hud-stats-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-track {
  position: relative;
  height: 11px;
  width: 100%;
  min-width: 170px;
  background: rgba(10, 12, 18, 0.72);
  border: 1.5px solid var(--glass-border);
  border-radius: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #d93829 0%, #ff9f1c 55%, #52e069 100%);
  transition: width 0.08s linear;
}

.progress-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 8px;
  color: #ffffff;
  text-shadow: 0 1px 1px #000;
}

.hud-sub-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.hud-pill {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 12px;
  color: #f8fafc;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid var(--glass-border);
  padding: 5px 10px;
  border-radius: 10px;
  letter-spacing: 0.4px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
  white-space: nowrap;
}

.aura-pill {
  color: var(--accent-gold);
}

.diff-pill {
  font-size: 11px;
  color: #ffb703;
  border-color: rgba(255, 183, 3, 0.45);
}

.diff-pill.mode-normal {
  color: #7ee081;
  border-color: rgba(126, 224, 129, 0.45);
}

.diff-pill.mode-hard {
  color: #ff6b6b;
  border-color: rgba(255, 107, 107, 0.5);
}

/* Title Screen Difficulty Selector */
.diff-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.diff-card {
  background: #23273b;
  border: 2.5px solid #485073;
  border-radius: 10px;
  padding: 10px 8px;
  color: #e2e8f0;
  cursor: pointer;
  text-align: center;
  transition: transform 0.08s, border-color 0.12s, background 0.12s;
  box-shadow: 3px 3px 0 #090a10;
}

.diff-card:hover {
  border-color: #cbd5e1;
}

.diff-card.active[data-diff="normal"] {
  background: #1c3627;
  border-color: #7ee081;
  color: #ffffff;
}

.diff-card.active[data-diff="hard"] {
  background: #3d1b20;
  border-color: #ff6b6b;
  color: #ffffff;
}

.diff-card:active {
  transform: translate(1px, 1px);
}

.diff-name {
  font-family: var(--font-px);
  font-size: 10px;
  margin-bottom: 5px;
}

.diff-troll {
  font-family: var(--font-ui);
  font-size: 9px;
  color: #cbd5e1;
}

.aura-pill.aura-negative {
  color: #ff6b6b;
  border-color: rgba(255, 107, 107, 0.45);
}

.rank-pill {
  font-size: 11px;
  color: #e2e8f0;
}

.bonk-pill {
  font-size: 11px;
  color: #fca5a5;
}

.timer-pill {
  font-size: 12px;
  color: #f1f5f9;
  padding: 7px 11px;
}

.hud-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1.5px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
  transition: transform 0.08s ease, background 0.15s;
}

.hud-icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.22);
}

/* =========================================================
   Floating Troll Toast Pill
   ========================================================= */
.troll-toast {
  position: absolute;
  top: calc(76px + var(--sat));
  left: 50%;
  transform: translate(-50%, -10px);
  z-index: 12;
  max-width: min(420px, 76vw);
  padding: 7px 14px;
  background: rgba(15, 17, 26, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 209, 102, 0.55);
  border-radius: 12px;
  font-size: 11px;
  color: #fff6db;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.troll-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* =========================================================
   Translucent iOS Multi-Touch Thumb Controls
   ========================================================= */
.touch-layer {
  position: absolute;
  left: calc(18px + var(--sal));
  right: calc(18px + var(--sar));
  bottom: calc(16px + var(--sab));
  z-index: 15;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.touch-layer.hidden {
  display: none;
}

.touch-layer.keyboard-dim {
  opacity: 0.38;
}

.touch-move-pad {
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: auto;
  touch-action: none;
  padding: 6px;
  border-radius: 24px;
}

.touch-action-pad {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  pointer-events: auto;
  touch-action: none;
}

.touch-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--touch-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 2px solid rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.92);
  font-family: var(--font-px);
  cursor: pointer;
  touch-action: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.06s ease, background 0.08s ease, border-color 0.08s ease;
}

.move-btn {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  font-size: 22px;
}

.jump-btn {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  font-size: 11px;
  background: rgba(217, 56, 41, 0.52);
  border-color: rgba(255, 235, 220, 0.45);
}

.retry-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 20px;
  margin-bottom: 4px;
}

.touch-btn.pressed, .touch-btn:active {
  transform: scale(0.92);
  background: var(--touch-active);
  border-color: #ffd166;
  color: #ffffff;
}

.jump-btn.pressed, .jump-btn:active {
  background: rgba(255, 92, 74, 0.78);
}

/* =========================================================
   Full-Screen Modal Overlays (Title, Worlds, Pause, Victory)
   ========================================================= */
.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(10, 12, 20, 0.78);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 470px;
  max-height: 90dvh;
  overflow-y: auto;
  text-align: center;
  background: #171a26;
  border: 3px solid #f4ecd8;
  border-radius: 14px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.65), 6px 6px 0 #090a10;
  padding: 20px 22px;
}

.modal-card.small {
  max-width: 340px;
}

.title-tag {
  font-family: var(--font-px);
  font-size: 9px;
  color: var(--accent-gold);
  margin-bottom: 10px;
  letter-spacing: 0.8px;
}

.pixel-title {
  font-family: var(--font-px);
  font-size: clamp(20px, 4vw, 30px);
  line-height: 1.3;
  margin: 0 0 8px;
  color: #fff6e5;
  text-shadow: 3px 3px 0 var(--accent-red);
}

.pixel-subtitle {
  font-family: var(--font-px);
  font-size: 14px;
  margin: 4px 0 12px;
  color: #fff6e5;
}

.title-footnote {
  font-size: 11px;
  color: #a8b2cc;
  margin-bottom: 18px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.modal-stack {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.pixel-btn {
  font-family: var(--font-px);
  font-size: 11px;
  padding: 12px 18px;
  border: 3px solid #f4ecd8;
  border-radius: 8px;
  background: #282e45;
  color: #fff6e5;
  cursor: pointer;
  box-shadow: 3px 3px 0 #090a10;
  transition: transform 0.06s, filter 0.1s;
}

.pixel-btn.primary {
  background: var(--accent-red);
}

.pixel-btn:hover {
  filter: brightness(1.12);
}

.pixel-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #090a10;
}

.controls-hint {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 10px;
  color: #c7d0e6;
}

.controls-hint b {
  color: var(--accent-gold);
}

.legal-footer {
  margin-top: 10px;
}

.legal-link {
  font-size: 10px;
  color: #94a3b8;
  text-decoration: underline;
  opacity: 0.85;
}

.legal-link:hover {
  color: #ffd166;
  opacity: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-px);
  font-size: 11px;
  color: var(--accent-gold);
  margin-bottom: 12px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.15);
  padding-bottom: 8px;
}

.tiny-link {
  background: transparent;
  border: 1.5px solid var(--accent-gold);
  border-radius: 6px;
  color: var(--accent-gold);
  font-family: var(--font-ui);
  font-size: 10px;
  padding: 3px 8px;
  cursor: pointer;
}

.world-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 7px;
  margin-bottom: 14px;
  max-height: 52dvh;
  overflow-y: auto;
  text-align: left;
  padding-right: 4px;
}

.world-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #24293d;
  border: 2px solid #485073;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 12px;
}

.world-item:hover:not(.locked) {
  border-color: var(--accent-gold);
  background: #2f3652;
}

.world-item.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.world-item .w-meta {
  font-size: 10px;
  color: #9ba6c7;
  margin-top: 2px;
}

.world-item .w-badge {
  font-family: var(--font-px);
  font-size: 8px;
  padding: 4px 7px;
  border-radius: 5px;
  background: #141724;
  color: #7ee081;
}

.world-item.locked .w-badge {
  color: #ff7b7b;
}

.modal-stats {
  font-size: 12px;
  line-height: 1.7;
  color: #d7e0f5;
  margin-bottom: 14px;
  background: rgba(0, 0, 0, 0.3);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.victory-quote {
  font-size: 11px;
  color: var(--accent-gold);
  font-style: italic;
  margin-bottom: 14px;
}

/* =========================================================
   Portrait Orientation Hint Banner (Phone Portrait Only)
   ========================================================= */
.rotate-banner {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(10, 12, 20, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.rotate-card {
  text-align: center;
  max-width: 300px;
  background: #171a26;
  border: 3px solid #f4ecd8;
  border-radius: 14px;
  padding: 22px;
}

.rotate-icon {
  font-size: 36px;
  margin-bottom: 10px;
}

.rotate-title {
  font-family: var(--font-px);
  font-size: 12px;
  color: var(--accent-gold);
  margin-bottom: 8px;
}

.rotate-sub {
  font-size: 12px;
  color: #cbd5e1;
  margin-bottom: 16px;
}

@media (max-width: 600px) and (orientation: portrait) {
  .rotate-banner:not(.dismissed) {
    display: flex;
  }
}

/* Compact adjustments for smaller landscape phones (e.g. iPhone SE / Mini) */
@media (max-height: 430px) {
  .dummy-cam-frame {
    width: 42px;
    height: 42px;
  }
  .dummy-cam-mood {
    font-size: 5px;
  }
  .hud-pill {
    font-size: 8px;
    padding: 4px 8px;
  }
  .rank-pill {
    display: none;
  }
  .move-btn {
    width: 58px;
    height: 58px;
    font-size: 18px;
  }
  .jump-btn {
    width: 72px;
    height: 72px;
    font-size: 10px;
  }
  .retry-btn {
    width: 44px;
    height: 44px;
    font-size: 16px;
  }
  .modal-card {
    padding: 14px 16px;
  }
}
