:root {
  --bg: #1a1a2e;
  --card: #16213e;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; height: 100dvh;
  overflow: hidden; position: fixed; width: 100%;
  touch-action: none;
  background: var(--bg);
  color: #fff;
  font-family: "Impact", "Arial Black", system-ui, sans-serif;
}
.app { height: 100dvh; display: flex; flex-direction: column; }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: flex; flex-direction: column; }

/* ===== MENU ===== */
#menuScreen {
  background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
  padding: 16px;
  gap: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.menuHeader { text-align: center; padding: 8px 0; }
.menuTitle {
  font-size: 32px; font-weight: 900;
  background: linear-gradient(135deg, #ff6b35, #ffdd57, #ff6b35);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  letter-spacing: 2px;
}
.menuSub { font-size: 14px; color: #a0a0c0; letter-spacing: 1px; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  flex: 1;
}
@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, 1fr); } }

/* Comic Game Tiles */
.tile {
  border-radius: 20px;
  padding: 16px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  min-height: 140px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,.25);
  box-shadow: 0 8px 20px rgba(0,0,0,.4), inset 0 2px 0 rgba(255,255,255,.2);
  transition: transform .12s ease, box-shadow .12s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.tile:active {
  transform: scale(.95);
  box-shadow: 0 4px 10px rgba(0,0,0,.5), inset 0 2px 0 rgba(255,255,255,.1);
}
/* Halftone dots overlay */
.tile::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle, rgba(0,0,0,.12) 1px, transparent 1px);
  background-size: 8px 8px;
  pointer-events: none;
}
.tile .emoji { font-size: 52px; filter: drop-shadow(2px 3px 2px rgba(0,0,0,.5)); z-index: 1; }
.tile .name {
  font-size: 18px; font-weight: 900; text-transform: uppercase;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 rgba(0,0,0,.6);
  z-index: 1;
}
.tile .info {
  font-size: 11px; color: rgba(255,255,255,.8);
  text-shadow: 1px 1px 0 rgba(0,0,0,.5);
  z-index: 1;
}
.tile .best {
  position: absolute; top: 8px; right: 10px;
  font-size: 11px; color: rgba(255,255,255,.7);
  background: rgba(0,0,0,.3); padding: 2px 8px; border-radius: 10px;
  z-index: 1;
}

/* Tile Colors */
.tile-indiaka   { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.tile-basket    { background: linear-gradient(135deg, #ff6b35, #e55d00); }
.tile-sally     { background: linear-gradient(135deg, #f1c40f, #e67e22); }
.tile-pullups   { background: linear-gradient(135deg, #27ae60, #1e8449); }
.tile-hockey    { background: linear-gradient(135deg, #3498db, #2471a3); }
.tile-rings     { background: linear-gradient(135deg, #8e44ad, #6c3483); }

/* Menu Footer */
.menuFooter { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.btnBig {
  width: 100%; padding: 14px;
  font-size: 18px; font-weight: 900; font-family: inherit;
  border: 3px solid rgba(255,255,255,.25);
  border-radius: 16px; cursor: pointer;
  background: linear-gradient(135deg, #ff6b35, #e74c3c);
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0,0,0,.4);
  box-shadow: 0 6px 15px rgba(0,0,0,.4);
  letter-spacing: 1px;
  -webkit-tap-highlight-color: transparent;
}
.btnBig:active { transform: scale(.97); }
.menuActions { display: flex; gap: 8px; }
.btnSmall {
  flex: 1; padding: 10px;
  font-size: 13px; font-weight: 800; font-family: inherit;
  border: 2px solid rgba(255,255,255,.15);
  border-radius: 12px; cursor: pointer;
  background: rgba(255,255,255,.08); color: #ccc;
  -webkit-tap-highlight-color: transparent;
}
.btnDanger { border-color: rgba(255,80,80,.3); color: #f88; }

/* ===== GAME SCREEN ===== */
#gameScreen { background: #000; }
#gameScreen canvas {
  width: 100%; height: 100%; display: block;
}
.btnFloat {
  position: absolute; z-index: 10;
  height: 40px;
  border-radius: 20px;
  border: 2px solid rgba(255,255,255,.4);
  background: rgba(0,0,0,.65);
  color: #fff; font-size: 14px; font-weight: 800;
  font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 0 16px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-tap-highlight-color: transparent;
}
.btnFloatLeft { top: 12px; left: 12px; }

.controls {
  position: absolute; bottom: 12px; left: 12px; right: 12px;
  display: flex; justify-content: space-between; align-items: flex-end;
  pointer-events: none; z-index: 6;
}
.joystick {
  width: 120px; height: 120px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.4);
  position: relative; pointer-events: auto; touch-action: none;
  display: none;
}
.stick {
  width: 44px; height: 44px; border-radius: 50%;
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255,255,255,.15);
  border: 2px solid rgba(255,255,255,.3);
}
.actionBtns {
  display: none; flex-direction: column; gap: 8px; pointer-events: auto;
}
.btnAction {
  width: 100px; padding: 14px 8px;
  border-radius: 14px; font-size: 14px; font-weight: 900; font-family: inherit;
  border: 2px solid rgba(255,255,255,.2);
  background: rgba(255,107,53,.3); color: #fff; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ===== RESULT & RANKING ===== */
#resultScreen, #rankingScreen {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  padding: 20px; gap: 16px; align-items: center; justify-content: center;
}
.resultCard {
  background: rgba(255,255,255,.06);
  border: 2px solid rgba(255,255,255,.12);
  border-radius: 20px; padding: 24px; text-align: center;
  max-width: 400px; width: 100%;
}
.resultScore {
  font-size: 64px; font-weight: 900;
  background: linear-gradient(135deg, #ffdd57, #ff6b35);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.resultLevel { font-size: 20px; color: #ffdd57; margin: 8px 0; }
.resultBtns { display: flex; gap: 10px; margin-top: 16px; justify-content: center; flex-wrap: wrap; }
.resultBtns button {
  padding: 12px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 800; font-family: inherit;
  border: 2px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08); color: #fff; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.resultBtns .primary {
  background: linear-gradient(135deg, #ff6b35, #e74c3c);
  border-color: rgba(255,255,255,.25);
}

/* Ranking */
.rankTable {
  width: 100%; max-width: 500px;
  border-collapse: collapse;
  background: rgba(255,255,255,.04);
  border-radius: 12px; overflow: hidden;
}
.rankTable th, .rankTable td {
  padding: 10px 12px; text-align: left;
  font-size: 13px; border-bottom: 1px solid rgba(255,255,255,.06);
}
.rankTable th { color: #ffdd57; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
