/* ============ Robonyte MOBILE — cleane Hochkant-UI ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --cyan: #4ff0e0;
  --yellow: #ffd24a;
  --red: #ff4d33;
  --ink: #e8ecff;
  --muted: #9aa6d0;
  --card: rgba(255, 255, 255, 0.045);
  --line: rgba(90, 110, 170, 0.35);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  background: #05070f;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Desktop-Fallback: Handy-Rahmen mittig (1:2). Auf echten Handys: randlos. */
#game {
  display: block;
  height: min(100vh, 200vw);
  width: calc(min(100vh, 200vw) / 2);
  background: #0b0e1a;
  box-shadow: 0 0 60px rgba(79, 240, 224, 0.12), 0 0 0 2px #1a2140;
  cursor: crosshair;
}
body.mobile #game {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  box-shadow: none;
  touch-action: none;
}

/* ============ Screens (Overlays über dem Live-Canvas) ============ */
.screen {
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: calc(min(100vh, 200vw) / 2);   /* am Desktop bündig mit dem Handy-Rahmen */
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--sat) + 68px) 20px calc(var(--sab) + 22px);
  background: linear-gradient(180deg, rgba(6,8,15,0.90) 0%, rgba(6,8,15,0.35) 38%, rgba(6,8,15,0.45) 62%, rgba(6,8,15,0.96) 100%);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
body.mobile .screen { max-width: none; }
.screen.hidden { display: none; }

/* ============ Topbar ============ */
.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--sat) + 12px) 16px 10px;
}
.stat {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(10, 14, 28, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px; font-weight: 700; color: #c8d0f0;
}
.stat b { color: #fff; }
.stat.gold { color: #ffe07a; border-color: rgba(190, 150, 50, 0.5); }
.stat.gold b { color: var(--yellow); }
.stat.push { margin-left: auto; }
.stat-lbl { font-size: 10px; letter-spacing: 1.5px; color: var(--muted); }

/* Gezeichnetes Münz-Icon statt Emoji */
.coin-dot {
  display: inline-block; width: 13px; height: 13px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe98a, #e0961a);
  box-shadow: inset 0 0 0 2px rgba(138, 90, 16, 0.55);
}
.coin-dot.sm { width: 9px; height: 9px; }

/* Zentrierter Screen-Titel in der Topbar */
.bar-title {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 17px; font-weight: 800; letter-spacing: 3px; color: #fff;
  text-shadow: 0 0 14px rgba(79,240,224,0.35);
  pointer-events: none;
}

.icon-btn {
  font-family: inherit; font-weight: 800; font-size: 12px; color: #dfe6ff;
  background: rgba(10, 14, 28, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 40px;
  padding: 7px 15px;
  cursor: pointer;
  letter-spacing: 1px;
  margin-left: auto;
}
.icon-btn.back { font-size: 13px; margin-left: 0; }
.icon-btn:active { transform: scale(0.95); }

/* ============ Lobby ============ */
.lobby-mid, .over-mid {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(8px, 2.4vh, 26px);
  width: 100%;
  flex: 1; min-height: 0;   /* zentriert Logo+Roboter im freien Raum über den Buttons */
}
.logo {
  font-size: clamp(34px, 11vw, 52px);
  font-weight: 800; letter-spacing: 4px; color: #fff;
  text-shadow: 0 0 22px rgba(79,240,224,0.45), 0 3px 0 #0a1830;
}
.logo .bolt { color: var(--yellow); text-shadow: 0 0 24px var(--yellow); }

.pedestal { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; }
.arrow {
  font-family: inherit; font-size: 30px; line-height: 1; font-weight: 700; color: #cfe0ff;
  width: 52px; height: 52px; flex: 0 0 52px; border-radius: 50%;
  background: rgba(10, 14, 28, 0.72);
  border: 1px solid var(--line);
  cursor: pointer;
}
.arrow:active { transform: scale(0.92); border-color: var(--cyan); }
.ped-stage { position: relative; display: flex; flex-direction: column; align-items: center; }
#preview {
  width: clamp(140px, 24vh, 210px);
  height: clamp(140px, 24vh, 210px);
  display: block;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.5));
}
.ped-disc {
  position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%);
  width: 62%; height: 26px; border-radius: 50%; z-index: -1;
  background: radial-gradient(ellipse at center, rgba(79,240,224,0.4), rgba(79,240,224,0) 70%);
}
.ped-name {
  margin-top: 2px; font-weight: 800; letter-spacing: 2px; color: #fff; font-size: 14px;
  background: rgba(10, 14, 28, 0.72); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 18px; text-transform: uppercase;
}

/* ============ Buttons ============ */
.lobby-actions {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; width: 100%; max-width: 400px;
}
.btn {
  font-family: inherit; font-weight: 800; letter-spacing: 1.5px;
  font-size: 15px; color: #dfe6ff;
  background: rgba(20, 27, 52, 0.9);
  border: 1px solid var(--line);
  border-radius: 16px;
  min-height: 52px;
  padding: 12px 20px;
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 0.08s;
}
.btn:active { transform: scale(0.97); }
.btn.xl { width: 100%; min-height: 60px; font-size: 19px; }
.btn.primary {
  background: linear-gradient(180deg, #22857a, #11534b);
  border-color: rgba(79, 240, 224, 0.6);
  color: #eafffb;
  box-shadow: 0 6px 22px rgba(79, 240, 224, 0.18);
}
.btn.auto {
  background: linear-gradient(180deg, #8a5a1e, #5a3a12);
  border-color: rgba(255, 176, 80, 0.6);
  color: #fff2df;
  box-shadow: 0 6px 22px rgba(255, 176, 80, 0.14);
}
.btn-row { display: flex; gap: 10px; width: 100%; }
.btn.half { flex: 1; }
.mode-note {
  font-size: 12px; color: var(--muted); text-align: center;
  max-width: 340px; line-height: 1.45;
}

/* ============ Screen-Titel ============ */
.screen-title {
  font-size: clamp(24px, 7vw, 32px); font-weight: 800; letter-spacing: 3px; color: #fff;
  text-shadow: 0 0 18px rgba(79,240,224,0.4);
}
.screen-title.over { color: var(--red); text-shadow: 0 0 20px rgba(255,77,51,0.55); }
.ov-best { color: #b6c0e6; font-size: 14px; }

/* Shop & Optionen: Inhalt oben andocken statt verteilen */
#shop, #options { justify-content: flex-start; }
#shop .screen-title, #options .screen-title { margin-top: 2px; }

/* ============ Tabs (segmentiert) ============ */
.tabs {
  display: flex; gap: 4px; width: 100%; max-width: 400px;
  background: rgba(10, 14, 28, 0.8);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px;
}
.tab {
  flex: 1;
  font-family: inherit; font-weight: 700; font-size: 13px; color: #aab6dc;
  background: transparent; border: 0; border-radius: 10px;
  min-height: 42px; padding: 8px 4px;
  cursor: pointer; white-space: nowrap;
}
.tab.active {
  color: #051014;
  background: linear-gradient(180deg, #3fd8c8, #23a596);
  box-shadow: 0 2px 10px rgba(79, 240, 224, 0.3);
}

/* ============ Skin-Grid ============ */
.shop-scroll {
  width: 100%; max-width: 400px; flex: 1; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 2px 2px 12px;
}
/* Vorschau-Panel: großes Live-Preview des angetippten Skins + Aktions-Button */
.shop-preview {
  width: 100%; max-width: 400px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 12px 14px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
#shopPreview {
  display: block; width: 100%; max-width: 280px; height: auto;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.45));
  border-radius: 12px;
}
.prev-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%;
}
.prev-name { font-size: 17px; font-weight: 800; letter-spacing: 1px; color: #fff; }
.prev-btn {
  min-height: 46px; padding: 10px 18px; border-radius: 12px;
  font-size: 13px; letter-spacing: 1px; white-space: nowrap;
}
.prev-btn.primary { box-shadow: none; }
.prev-btn.owned { color: var(--cyan); border-color: rgba(79,240,224,0.5); background: transparent; opacity: 1; }
.prev-btn:disabled { opacity: 0.55; }
.prev-btn.buy { border-color: rgba(190, 150, 50, 0.6); color: #ffe07a; }

/* Kachel-Grid: nur Farb-Swatches, Details oben in der Vorschau */
.skin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile {
  position: relative;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 13px;
  padding: 6px 6px 5px; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; align-items: stretch;
}
.tile:active { transform: scale(0.95); }
.tile .sw {
  display: block; height: 42px; border-radius: 8px; position: relative;
  border: 1px solid rgba(0,0,0,0.4);
}
.tile .sw .dot {
  position: absolute; right: 5px; bottom: 5px; width: 9px; height: 9px; border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
}
.tile .tl {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  min-height: 14px; overflow: hidden; white-space: nowrap;
}
.tile.locked .sw { filter: saturate(0.35) brightness(0.55); }
.tile.focus { border-color: #e8ecff; }
.tile.active { border-color: var(--cyan); box-shadow: 0 0 12px rgba(79,240,224,0.22); }
.tile.active::after {
  content: ''; position: absolute; top: -4px; right: -4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--cyan); border: 2px solid #0a0e1c;
}

/* ============ Optionen ============ */
.opt-list { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 10px; }
.opt-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px;
  font-size: 15px; font-weight: 700; color: #dfe6ff;
}
.toggle {
  font-family: inherit; font-weight: 700; font-size: 13px; letter-spacing: 1px; color: #eafffb;
  background: linear-gradient(180deg, #1e6f66, #124a44);
  border: 1px solid rgba(79, 240, 224, 0.6); border-radius: 12px;
  min-height: 42px; padding: 9px 18px; cursor: pointer; min-width: 84px;
}
.toggle.danger { background: linear-gradient(180deg, #7a2233, #4a1420); border-color: rgba(255, 77, 106, 0.7); color: #ffd7de; }
.toggle:active { transform: scale(0.96); }
.opt-note { font-size: 12px; color: #8a95bd; text-align: center; margin-top: 4px; line-height: 1.45; }

/* ============ Game Over ============ */
#over { justify-content: center; gap: 20px; }
.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  width: 100%; max-width: 360px;
}
.stat-grid > div { background: rgba(10, 14, 28, 0.75); border: 1px solid var(--line); border-radius: 14px; padding: 12px 10px; text-align: center; }
.stat-grid span { display: block; font-size: 11px; color: #90a0d0; text-transform: uppercase; letter-spacing: 1px; }
.stat-grid b { font-size: 24px; color: #fff; }

/* ============ Pause ============ */
.pause-btn {
  position: absolute; top: calc(var(--sat) + 10px); left: 50%; transform: translateX(-50%);
  z-index: 12;
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(10, 14, 28, 0.72); border: 1px solid var(--line); color: #dfe6ff;
  font-size: 17px; cursor: pointer;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.pause-btn:active { transform: translateX(-50%) scale(0.92); }
.pause-btn { display: flex; align-items: center; justify-content: center; }
.pause-btn.hidden { display: none; }
/* Zwei gezeichnete Pause-Balken statt Emoji */
.pbars { position: relative; width: 12px; height: 15px; }
.pbars::before, .pbars::after {
  content: ''; position: absolute; top: 0; width: 4px; height: 15px;
  background: #dfe6ff; border-radius: 2px;
}
.pbars::before { left: 0; }
.pbars::after { right: 0; }
#paused { justify-content: center; gap: 24px; }
.pause-actions {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; width: 100%; max-width: 400px;
}

/* ============ Querformat-Hinweis (nur Handy) ============ */
#rotate { display: none; }
@media (orientation: landscape) {
  body.mobile #rotate {
    display: flex; position: fixed; inset: 0; z-index: 100;
    flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    background: #070a12; color: #dfe6ff; text-align: center; padding: 8vw;
  }
  body.mobile #rotate .rot-phone {
    width: 40px; height: 68px; border: 3px solid #dfe6ff; border-radius: 10px;
    box-shadow: inset 0 -8px 0 rgba(223,230,255,0.35);
    animation: rotHint 1.8s ease-in-out infinite;
  }
  body.mobile #rotate h2 { font-size: 22px; letter-spacing: 2px; color: #fff; }
  body.mobile #rotate p { font-size: 15px; color: #9aa6d0; }
}
@keyframes rotHint { 0%,100% { transform: rotate(78deg); } 50% { transform: rotate(-2deg); } }

/* Sehr kleine/niedrige Screens: kompakter */
@media (max-height: 640px) {
  .screen { padding-top: calc(var(--sat) + 56px); gap: 8px; }
  .logo { font-size: 30px; }
  #preview { width: 120px; height: 120px; }
  .btn.xl { min-height: 52px; font-size: 16px; }
  .mode-note { display: none; }
}
