/* Iplay - Design system
   1. Fondations   2. Composants   3. Ecrans app   4. Administration   5. Responsive */

/* ============================ 1. FONDATIONS ============================ */
:root {
  --bg: #0B1020;
  --bg-2: #0F1730;
  --surface: #161E3C;
  --surface-2: #1E2750;
  --line: rgba(255, 255, 255, .09);
  --line-2: rgba(255, 255, 255, .16);
  --text: #F2F5FF;
  --muted: rgba(242, 245, 255, .60);
  --muted-2: rgba(242, 245, 255, .42);
  --mint: #02C39A;
  --violet: #7C5CFF;
  --orange: #FF7A45;
  --gold: #F2C14E;
  --pink: #FF4D8D;
  --blue: #2E9BFF;
  --danger: #FF5C6C;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 40px rgba(3, 6, 20, .45);
  --nav-h: 68px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

body {
  background-image:
    radial-gradient(900px 520px at 12% -8%, rgba(124, 92, 255, .22), transparent 62%),
    radial-gradient(760px 520px at 92% 4%, rgba(2, 195, 154, .18), transparent 60%);
  background-repeat: no-repeat;
  min-height: 100vh;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 700; }
h1 { font-size: 1.6rem; letter-spacing: -.02em; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1rem; }
p { margin: 0; line-height: 1.6; }
a { color: var(--mint); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { flex: none; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ============================ 2. COMPOSANTS ============================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .78rem 1.1rem; border-radius: 999px; border: 1px solid transparent;
  background: var(--surface-2); color: var(--text); font-weight: 650; font-size: .95rem;
  cursor: pointer; text-decoration: none; transition: transform .16s ease, filter .16s ease, opacity .16s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--mint), #04A88A); color: #04121A; }
.btn-violet { background: linear-gradient(135deg, var(--violet), #5B3BE0); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--text); }
.btn-danger { background: rgba(255, 92, 108, .14); border-color: rgba(255, 92, 108, .38); color: #FFB3BB; }
.btn-sm { padding: .5rem .8rem; font-size: .84rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }

.card {
  background: linear-gradient(180deg, rgba(30, 39, 80, .82), rgba(22, 30, 60, .82));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: .9rem; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .9rem; }

.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 700;
  background: rgba(255, 255, 255, .08); color: var(--muted); border: 1px solid var(--line);
  text-transform: uppercase; letter-spacing: .04em;
}
.badge-mint { background: rgba(2, 195, 154, .14); color: #63E7C7; border-color: rgba(2, 195, 154, .34); }
.badge-violet { background: rgba(124, 92, 255, .16); color: #B9A7FF; border-color: rgba(124, 92, 255, .34); }
.badge-orange { background: rgba(255, 122, 69, .16); color: #FFB08C; border-color: rgba(255, 122, 69, .32); }
.badge-gold { background: rgba(242, 193, 78, .16); color: #FFDD97; border-color: rgba(242, 193, 78, .32); }
.badge-danger { background: rgba(255, 92, 108, .16); color: #FFB3BB; border-color: rgba(255, 92, 108, .34); }

.chip-row { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
  padding: .45rem .8rem; border-radius: 999px; border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, .04); color: var(--muted); font-size: .82rem; font-weight: 600;
  cursor: pointer;
}
.chip.is-active { background: rgba(2, 195, 154, .16); border-color: rgba(2, 195, 154, .45); color: #7FEFD3; }

.field { display: block; margin-bottom: .85rem; }
.field > span { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .35rem; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: .78rem .9rem; border-radius: var(--radius-sm);
  background: rgba(8, 12, 28, .7); border: 1px solid var(--line-2); color: var(--text);
}
.field textarea { min-height: 108px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--mint); box-shadow: 0 0 0 3px rgba(2, 195, 154, .16);
}
.field-inline { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.field-inline .field { flex: 1 1 200px; margin-bottom: 0; }

.form-error {
  background: rgba(255, 92, 108, .12); border: 1px solid rgba(255, 92, 108, .34);
  color: #FFC2C9; border-radius: var(--radius-sm); padding: .7rem .9rem; font-size: .88rem; margin-bottom: .9rem;
}
.form-ok {
  background: rgba(2, 195, 154, .12); border: 1px solid rgba(2, 195, 154, .34);
  color: #9FF2DC; border-radius: var(--radius-sm); padding: .7rem .9rem; font-size: .88rem; margin-bottom: .9rem;
}

.toast-zone {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 14px);
  display: flex; flex-direction: column; align-items: center; gap: .5rem; z-index: 120; pointer-events: none;
  padding: 0 16px;
}
.toast {
  background: rgba(20, 27, 55, .97); border: 1px solid var(--line-2); color: var(--text);
  padding: .7rem 1rem; border-radius: 999px; font-size: .86rem; box-shadow: var(--shadow);
  max-width: 420px; text-align: center;
}
.toast.is-ok { border-color: rgba(2, 195, 154, .5); }
.toast.is-err { border-color: rgba(255, 92, 108, .5); }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .2); border-top-color: var(--mint);
  animation: spin .8s linear infinite; margin: 1.4rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center; padding: 2rem 1rem; color: var(--muted);
  border: 1px dashed var(--line-2); border-radius: var(--radius-sm);
}

.table-wrap { width: 100%; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th, table.data td { text-align: left; padding: .7rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; }
table.data tr:last-child td { border-bottom: none; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: #05121B; flex: none; font-size: .95rem;
}

/* ============================ 3. ECRANS APP ============================ */
.topbar {
  position: sticky; top: 0; z-index: 90;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(11, 16, 32, .88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  padding: .7rem 16px; max-width: 1080px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .logo-mark {
  width: 38px; height: 38px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--mint), var(--violet)); color: #06121C;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1.06rem; letter-spacing: -.01em; }
.brand-text small { font-size: .7rem; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }

.page { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 34px); }
.section { margin-top: 1.6rem; }
.section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .5rem; margin-bottom: .85rem; }

.hero {
  position: relative; overflow: hidden; border-radius: var(--radius);
  border: 1px solid var(--line); margin-top: 1rem;
  min-height: 290px; display: flex; align-items: flex-end;
  background: linear-gradient(150deg, rgba(124, 92, 255, .35), rgba(2, 195, 154, .22)), var(--surface);
}
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .38; }
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(11, 16, 32, .12) 20%, rgba(11, 16, 32, .93) 88%);
}
.hero-content { position: relative; z-index: 2; padding: 1.3rem 1.2rem; width: 100%; }
.hero h1 { font-size: 1.75rem; margin-bottom: .5rem; }
.hero p { color: rgba(242, 245, 255, .82); max-width: 620px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }

.banniere {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  background: rgba(2, 195, 154, .1); border: 1px solid rgba(2, 195, 154, .3);
  border-radius: var(--radius-sm); padding: .8rem 1rem; font-size: .86rem; margin-top: 1rem;
}

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; margin-top: 1rem; }
.stat {
  background: linear-gradient(180deg, rgba(30, 39, 80, .8), rgba(22, 30, 60, .8));
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .85rem;
}
.stat strong { display: block; font-size: 1.35rem; letter-spacing: -.02em; }
.stat span { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.game-grid { display: grid; grid-template-columns: 1fr; gap: .9rem; }
.game-card {
  position: relative; display: block; color: var(--text); border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--line); min-height: 210px;
  background: var(--surface); box-shadow: var(--shadow);
  transition: transform .18s ease, border-color .18s ease;
}
.game-card:hover { text-decoration: none; transform: translateY(-3px); border-color: var(--line-2); }
.game-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.game-card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(11, 16, 32, .18) 10%, rgba(11, 16, 32, .95) 82%);
}
.game-card-body { position: relative; z-index: 2; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; min-height: 210px; justify-content: flex-end; }
.game-card h3 { font-size: 1.08rem; }
.game-card p { font-size: .85rem; color: rgba(242, 245, 255, .74); }
.game-card .game-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .3rem; }
.game-accent { position: absolute; top: 0; left: 0; right: 0; height: 4px; z-index: 3; }

.rank-list { display: flex; flex-direction: column; gap: .5rem; }
.rank-row {
  display: flex; align-items: center; gap: .75rem;
  background: rgba(255, 255, 255, .03); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .65rem .8rem;
}
.rank-pos {
  width: 28px; height: 28px; border-radius: 9px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; background: rgba(255, 255, 255, .08); color: var(--muted);
}
.rank-row.is-top .rank-pos { background: linear-gradient(135deg, var(--gold), #D79E1F); color: #1A1200; }
.rank-main { flex: 1 1 auto; min-width: 0; }
.rank-main strong { display: block; font-size: .94rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-main small { color: var(--muted); font-size: .76rem; }
.rank-score { font-weight: 700; font-size: 1rem; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  background: rgba(13, 18, 38, .96); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav-inner {
  display: flex; align-items: stretch; justify-content: space-around;
  max-width: 620px; margin: 0 auto; height: var(--nav-h);
}
.nav-item {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .22rem; color: var(--muted); font-size: .68rem; font-weight: 650; text-decoration: none;
  padding: .4rem .2rem; letter-spacing: .01em;
}
.nav-item:hover { text-decoration: none; color: var(--text); }
.nav-item.is-active { color: var(--mint); }
.nav-item svg { width: 22px; height: 22px; }

/* Jeu */
.game-stage {
  position: relative; width: 100%; border-radius: var(--radius);
  border: 1px solid var(--line); background: #080C1C; overflow: hidden;
  margin-top: .9rem;
}
.game-stage canvas { display: block; width: 100%; height: auto; touch-action: none; }
.game-hud {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem;
  margin-top: .8rem;
}
.hud-item { display: flex; flex-direction: column; }
.hud-item span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hud-item strong { font-size: 1.15rem; }
.game-overlay {
  position: absolute; inset: 0; z-index: 5; background: rgba(8, 12, 28, .88);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: .8rem; padding: 1.2rem;
}
.game-overlay h3 { font-size: 1.3rem; }
.game-overlay p { color: var(--muted); font-size: .9rem; max-width: 320px; }
.touch-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; max-width: 260px; margin: .9rem auto 0; }
.touch-pad button {
  padding: .9rem 0; border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, .05); color: var(--text); font-size: 1.1rem; font-weight: 700;
}
.touch-pad button:active { background: rgba(2, 195, 154, .2); }

.profil-head { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.profil-head .avatar { width: 58px; height: 58px; font-size: 1.25rem; }

.offline-badge {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 50%; transform: translateX(-50%);
  z-index: 150; background: rgba(242, 193, 78, .16); border: 1px solid rgba(242, 193, 78, .4);
  color: #FFE0A3; border-radius: 999px; padding: .35rem .8rem; font-size: .78rem; font-weight: 650;
}

.install-btn svg { width: 17px; height: 17px; }

/* ============================ 4. ADMINISTRATION ============================ */
.admin-body { background: var(--bg); }
.admin-topbar {
  position: sticky; top: 0; z-index: 90; padding-top: env(safe-area-inset-top, 0px);
  background: rgba(9, 13, 28, .92); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.admin-tabs {
  display: flex; gap: .4rem; overflow-x: auto; padding: .55rem 16px;
  max-width: 1080px; margin: 0 auto; scrollbar-width: none;
}
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tab {
  padding: .5rem .85rem; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04); color: var(--muted); font-size: .84rem; font-weight: 650;
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.admin-tab.is-active { background: rgba(2, 195, 154, .16); border-color: rgba(2, 195, 154, .45); color: #7FEFD3; }
.admin-panel { margin-top: 1.2rem; }
.admin-grid { display: grid; grid-template-columns: 1fr; gap: .9rem; }
.chart-box { position: relative; height: 250px; width: 100%; }

.lock-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
}
.lock-card { width: 100%; max-width: 430px; }

.domaine-banner {
  background: rgba(2, 195, 154, .1); border: 1px solid rgba(2, 195, 154, .3);
  border-radius: var(--radius-sm); padding: 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .8rem;
}
.domaine-banner .db-label { font-size: .86rem; color: #7FEFD3; font-weight: 700; }
.domaine-banner p { font-size: .84rem; color: var(--muted); flex: 1 1 260px; }

/* ============================ 5. AUTHENTIFICATION ============================ */
.auth-body { min-height: 100vh; }
.auth-wrap {
  min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
  gap: 1.2rem; max-width: 460px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 32px) 16px calc(env(safe-area-inset-bottom, 0px) + 32px);
}
.auth-brand { display: flex; align-items: center; gap: .7rem; justify-content: center; text-align: left; }
.auth-brand .logo-mark {
  width: 46px; height: 46px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--mint), var(--violet)); color: #06121C;
}
.auth-brand-text { display: flex; flex-direction: column; }
.auth-brand-text strong { font-size: 1.2rem; }
.auth-brand-text small { color: var(--muted); font-size: .78rem; }
.auth-card { background: rgba(22, 30, 60, .8); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.35rem; margin-bottom: .35rem; }
.auth-sub { color: var(--muted); font-size: .88rem; margin-bottom: 1.1rem; }
.auth-foot { text-align: center; font-size: .86rem; color: var(--muted); margin-top: .9rem; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; background: rgba(5, 8, 20, .78);
  display: flex; align-items: flex-end; justify-content: center; padding: 16px;
}
.modal {
  width: 100%; max-width: 430px; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow);
  margin-bottom: env(safe-area-inset-bottom, 0px);
}
.modal h3 { margin-bottom: .5rem; }
.modal p { color: var(--muted); font-size: .88rem; margin-bottom: .9rem; }
.modal ol { margin: 0 0 1rem; padding-left: 1.1rem; color: var(--muted); font-size: .88rem; line-height: 1.7; }
.store-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: .9rem; }
.store-pill {
  display: inline-flex; align-items: center; gap: .5rem; padding: .5rem .8rem;
  border: 1px solid var(--line-2); border-radius: 12px; font-size: .8rem; color: var(--muted);
}

.footer-app { margin-top: 2rem; padding-top: 1.2rem; border-top: 1px solid var(--line); color: var(--muted-2); font-size: .8rem; }
.footer-app .footer-links { display: flex; flex-wrap: wrap; gap: .8rem; margin-bottom: .6rem; }

/* ============================ 6. RESPONSIVE ============================ */
@media (min-width: 560px) {
  .game-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .hero { min-height: 340px; }
  .hero h1 { font-size: 2.1rem; }
  .admin-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 900px) {
  .game-grid { grid-template-columns: repeat(3, 1fr); }
  .admin-grid-3 { grid-template-columns: repeat(3, 1fr); }
  .hero { min-height: 400px; }
  .hero h1 { font-size: 2.5rem; }
  .container { padding: 0 24px; }
}

@media (max-width: 767px) {
  .table-cards thead { display: none; }
  .table-cards tbody tr {
    display: block; border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: .7rem .8rem; margin-bottom: .6rem; background: rgba(255, 255, 255, .03);
  }
  .table-cards tbody td { display: flex; justify-content: space-between; gap: 1rem; border: none; padding: .3rem 0; }
  .table-cards tbody td::before {
    content: attr(data-label); color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
  }
  .touch-pad { display: grid; }
}

@media (max-width: 480px) {
  h1 { font-size: 1.4rem; }
  .hero h1 { font-size: 1.6rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-box { height: 220px; }
}

#fileAttenteBadge { top: calc(env(safe-area-inset-top, 0px) + 48px); }

/* Pages de connexion : la barre de navigation occupe le bas de l ecran */
.auth-wrap {
  min-height: auto;
  padding-top: calc(env(safe-area-inset-top, 0px) + 34px);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 34px);
}
