:root {
  --deep-navy: #070b1e;
  --midnight: #10173b;
  --royal-purple: #231651;
  --card-surface: rgba(20, 28, 68, 0.84);
  --card-border: rgba(255, 213, 79, 0.28);
  --gold: #ffd54f;
  --amber: #ffa000;
  --emerald: #00e676;
  --cyan: #00e5ff;
  --crimson: #ff5252;
  --text: #f8fafc;
  --muted: #b0bec5;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; min-height: 100vh;
  background: linear-gradient(180deg, #0a0f2c 0%, #141848 52%, #090d24 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overflow-x: hidden;
}

#bgAuroraCanvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}

.app-shell {
  position: relative; z-index: 1;
  max-width: 540px; min-height: 100vh;
  margin: 0 auto; padding: 12px 14px 28px;
}

.glass-card {
  background: var(--card-surface);
  border: 1.5px solid var(--card-border);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.42);
}

.glass-card.clickable { cursor: pointer; transition: transform 0.14s ease, border-color 0.15s ease; }
.glass-card.clickable:active { transform: scale(0.985); }
.glass-card.gold-border { border-color: var(--gold); }
.glass-card.emerald-border { border-color: var(--emerald); }
.glass-card.cyan-border { border-color: var(--cyan); }

/* Header & Coins Pill */
.top-screen-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.icon-circle-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.09); color: #fff; font-size: 1.05rem;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.top-screen-title {
  flex: 1; font-weight: 900; font-size: 1.12rem; letter-spacing: 0.4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.coin-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  background: linear-gradient(90deg, rgba(255, 213, 79, 0.2), rgba(255, 160, 0, 0.2));
  border: 1.2px solid rgba(255, 213, 79, 0.65); color: var(--gold);
  font-weight: 900; font-size: 0.85rem; white-space: nowrap;
}

/* Profile Card Top */
.profile-header-card { padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.avatar-ring {
  position: relative; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; flex-shrink: 0;
  padding: 3px;
}
.avatar-inner {
  width: 100%; height: 100%; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255,255,255,0.22);
}
.rank-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 8px; font-size: 0.7rem; font-weight: 800;
}
.xp-bar-track {
  width: 100%; max-width: 240px; height: 6px; border-radius: 999px;
  background: rgba(255,255,255,0.16); overflow: hidden; margin: 5px 0 3px;
}
.xp-bar-fill { height: 100%; background: var(--cyan); border-radius: 999px; transition: width 0.3s ease; }

/* 3D Logo Banner */
.logo-3d-wrap { text-align: center; margin: 10px 0 12px; }
.logo-crown-orb {
  width: 56px; height: 56px; margin: 0 auto 6px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff59d, #ffd54f 45%, #ff8f00);
  box-shadow: 0 8px 24px rgba(255, 179, 0, 0.45), inset 0 -3px 6px rgba(120, 60, 0, 0.4);
  display: flex; align-items: center; justify-content: center; font-size: 1.75rem;
}
.logo-title {
  font-weight: 900; font-size: 1.48rem; letter-spacing: 1.4px;
  background: linear-gradient(90deg, #fff8e1, #ffd54f, #ffb300);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 16px rgba(0,0,0,0.45);
}
.logo-sub {
  font-size: 0.68rem; font-weight: 800; letter-spacing: 3px;
  color: var(--cyan); margin-top: 1px;
}

/* Home Mode Tiles matching Android */
.hero-cta-card {
  width: 100%; border: none; border-radius: 20px; padding: 16px 18px;
  background: linear-gradient(110deg, #ffd54f 0%, #ff8f00 55%, #ff6f00 100%);
  color: #1a0f00; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; text-align: left; box-shadow: 0 12px 28px rgba(255, 136, 0, 0.38);
  transition: transform 0.14s ease;
}
.hero-cta-card:active { transform: scale(0.985); }

.mode-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.mode-tile {
  border: 1px solid rgba(255,255,255,0.22); border-radius: 18px; padding: 13px 12px;
  color: #fff; text-align: left; cursor: pointer; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; min-height: 82px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3); transition: transform 0.14s ease;
}
.mode-tile:active { transform: scale(0.98); }
.mode-tile .m-ico { font-size: 1.35rem; margin-bottom: 5px; }
.mode-tile .m-title { font-weight: 900; font-size: 0.93rem; line-height: 1.15; }
.mode-tile .m-sub { font-size: 0.72rem; opacity: 0.88; margin-top: 3px; font-weight: 600; }

.hub-label {
  margin: 15px 0 8px; color: var(--gold); font-weight: 900;
  font-size: 0.76rem; letter-spacing: 1.5px; text-transform: uppercase;
}
.hub-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hub-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.hub-btn {
  position: relative; background: var(--card-surface);
  border: 1px solid rgba(255,255,255,0.16); border-radius: 16px;
  padding: 12px 8px; text-align: center; cursor: pointer; color: #fff;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.hub-btn:active { transform: scale(0.98); }
.hub-badge-dot {
  position: absolute; top: 8px; right: 10px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--crimson); box-shadow: 0 0 8px var(--crimson);
}

/* Inputs, Chips & Buttons */
.royal-btn {
  border: none; border-radius: 14px; padding: 12px 16px;
  font-weight: 900; font-size: 0.86rem; cursor: pointer;
  background: linear-gradient(90deg, #ffd54f, #ff8f00); color: #160e00;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform 0.12s ease, opacity 0.15s ease;
}
.royal-btn:active { transform: scale(0.98); }
.royal-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.royal-btn.cyan { background: linear-gradient(90deg, #4dd0e1, #0288d1); color: #fff; }
.royal-btn.emerald { background: linear-gradient(90deg, #43a047, #1b5e20); color: #fff; }
.royal-btn.blue { background: linear-gradient(90deg, #4285f4, #1a73e8); color: #fff; }
.royal-btn.danger { background: linear-gradient(90deg, #ff5252, #b71c1c); color: #fff; }
.royal-btn.ghost {
  background: rgba(255,255,255,0.08); color: #fff; border: 1px solid rgba(255,255,255,0.22);
}

.field-input, .field-select {
  width: 100%; padding: 11px 13px; border-radius: 12px;
  border: 1.5px solid rgba(255,255,255,0.2); background: rgba(7, 11, 30, 0.85);
  color: #fff; font-size: 0.92rem; outline: none;
}
.field-input:focus, .field-select:focus { border-color: var(--gold); }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn {
  flex: 1; min-width: 82px; padding: 9px 10px; border-radius: 12px; cursor: pointer;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.18);
  color: #e2e8f0; font-weight: 800; font-size: 0.8rem; text-align: center;
}
.chip-btn.selected {
  background: rgba(255, 213, 79, 0.22); border-color: var(--gold); color: var(--gold);
}

.tabs-bar {
  display: flex; border-bottom: 1px solid rgba(255,255,255,0.14); margin-bottom: 12px;
}
.tab-line-btn {
  flex: 1; padding: 10px 6px; border: none; background: transparent;
  color: var(--muted); font-weight: 800; font-size: 0.84rem; cursor: pointer;
  border-bottom: 2.5px solid transparent;
}
.tab-line-btn.active { color: var(--gold); border-bottom-color: var(--gold); }

/* Game Screen Layout (Exact 2 Corner Top + Board + 2 Corner Bottom) */
.game-top-bar {
  display: flex; align-items: center; gap: 6px; margin-bottom: 8px;
}
.game-meme-pill {
  padding: 5px 9px; border-radius: 999px; font-size: 0.7rem; font-weight: 900; cursor: pointer;
  border: 1px solid rgba(255,213,79,0.5); background: rgba(255,213,79,0.18); color: var(--gold);
  white-space: nowrap;
}
.game-meme-pill.off {
  border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.08); color: var(--muted);
}

.corner-hud-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0;
}
.corner-hud {
  background: rgba(18, 24, 58, 0.78);
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px; padding: 6px; display: flex; align-items: center; gap: 5px;
  transition: opacity 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  min-width: 0;
}
.corner-hud.active { border-color: var(--gold); box-shadow: 0 0 14px rgba(255,213,79,0.3); }
.corner-hud.eliminated { opacity: 0.45; }

.hud-info { flex: 1; min-width: 0; }
.hud-name { font-weight: 800; font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-dots { display: flex; align-items: center; gap: 3px; margin-top: 3px; }
.hud-dot { width: 7px; height: 7px; border-radius: 50%; border: 1px solid #fff; }

.dice-timer-box {
  position: relative; width: 52px; height: 52px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.dice-timer-svg {
  position: absolute; inset: 0; width: 52px; height: 52px; transform: rotate(-90deg); pointer-events: none;
}
canvas.dice3d-canvas {
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
  transition: transform 0.16s ease;
}
canvas.dice3d-canvas.can-roll {
  box-shadow: 0 0 14px rgba(255,213,79,0.65); animation: dicePulse 0.75s ease-in-out infinite alternate;
}
canvas.dice3d-canvas.rolling { animation: diceSpin 0.26s linear infinite; }
@keyframes dicePulse { from { transform: scale(1); } to { transform: scale(1.1); } }
@keyframes diceSpin { from { transform: scale(1.12) rotate(0deg); } to { transform: scale(1.12) rotate(360deg); } }

.board-stage {
  position: relative; width: 100%; margin: 5px 0;
}
canvas#ludoBoardCanvas {
  width: 100%; aspect-ratio: 1 / 1; display: block;
  border-radius: 14px; cursor: pointer; touch-action: manipulation;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}

.meme-banner-pill {
  margin: 6px auto 0; max-width: 92%;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(16, 23, 59, 0.94); border: 1.5px solid var(--gold);
  color: var(--gold); font-weight: 900; font-size: 0.8rem; text-align: center;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
}

.status-banner {
  margin-top: 6px; padding: 9px 12px; border-radius: 14px; text-align: center;
  background: rgba(20, 28, 68, 0.85); border: 1px solid rgba(255,255,255,0.14);
  font-weight: 700; font-size: 0.82rem; color: #f1f5f9;
}

.mini-cam-video {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--cyan); background: #000;
}

/* Modal / Overlay */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(6, 9, 24, 0.84);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card {
  width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  background: #10173b; border: 1.5px solid var(--gold); border-radius: 22px; padding: 18px;
}
.hidden { display: none !important; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.toast-pill {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: #10173b; border: 1.5px solid var(--gold); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-weight: 800; font-size: 0.86rem;
  box-shadow: 0 10px 28px rgba(0,0,0,0.5);
}
