:root {
  --bg: #0f1220;
  --bg-elevated: #171b2e;
  --card: #1c2138;
  --card-active: #262c4a;
  --text: #f4f5fa;
  --text-dim: #9aa0c0;
  --accent: #7c8cff;
  --border: #2a2f4a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

a { color: inherit; text-decoration: none; }

/* ---------- Dashboard header ---------- */

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(14px + var(--safe-top)) 16px 14px;
  background: linear-gradient(180deg, var(--bg) 60%, rgba(15,18,32,0.85) 100%);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.header p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}

/* ---------- Home page: one full game block per game ---------- */

.game-list {
  padding-bottom: calc(24px + var(--safe-bottom));
}

.game-block {
  position: relative;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.game-block:first-child {
  border-top: 0;
}

.game-rank {
  position: absolute;
  top: 30px;
  left: 16px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

@media (min-width: 760px) {
  .game-rank { left: 24px; }
}

.empty-state {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

/* ---------- Player page ---------- */

.player-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--card);
  font-size: 20px;
  flex-shrink: 0;
}

.back-btn:active { background: var(--card-active); }

.player-header .title {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Game detail page (preview + description + mechanics) ---------- */

.detail {
  padding: 20px 16px calc(32px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1100px;
  margin: 0 auto;
}

.preview-col {
  display: flex;
  justify-content: center;
}

.phone-frame {
  width: min(78vw, 300px);
  aspect-ratio: 9 / 19.5;
  background: #05060a;
  border-radius: 34px;
  padding: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.45), inset 0 0 0 2px #23283f;
  position: relative;
}

.phone-notch {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 34%;
  height: 18px;
  background: #05060a;
  border-radius: 0 0 12px 12px;
  z-index: 2;
}

.phone-screen {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phone-screen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.play-now-btn {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(124,140,255,0.45);
}

.play-now-btn:active { transform: translateX(-50%) scale(0.96); }

.play-icon { font-size: 13px; }

.info-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
}

.info-label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.info-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 800;
}

.info-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-dim);
}

.mechanics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 420px) {
  .mechanics-grid { grid-template-columns: 1fr 1fr; }
}

.mechanic-tile {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.mechanic-tile .m-icon {
  font-size: 20px;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 25%, var(--bg-elevated));
}

.mechanic-tile .m-title {
  margin: 0 0 3px;
  font-size: 13.5px;
  font-weight: 700;
}

.mechanic-tile .m-text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-dim);
}

@media (min-width: 760px) {
  .detail {
    flex-direction: row;
    align-items: flex-start;
    padding-top: 32px;
  }
  .preview-col {
    position: sticky;
    top: 88px;
    flex: 0 0 auto;
  }
  .info-col {
    flex: 1 1 auto;
  }
}

/* Full-screen play overlay, opened by the Play Now button */

.play-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #000;
  display: flex;
  flex-direction: column;
}

.play-overlay[hidden] { display: none; }

.play-overlay-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.play-overlay-bar .title {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.play-overlay-frame {
  flex: 1 1 auto;
  position: relative;
}

.play-overlay-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.player-fallback {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 60;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  background: var(--bg);
}

.player-fallback.visible { display: flex; }

.player-fallback .btn {
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}
