* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg-top: #10222c;
  --bg-bot: #081016;
  --panel: #16283299;
  --panel-solid: #1a2e3a;
  --panel-light: #22384499;
  --accent: #5ac8d2;
  --gold: #f0c65c;
  --green: #2a7850;
  --green-h: #349860;
  --blue: #2f5f8a;
  --text: #f0f4f6;
  --soft: #c8d2d6;
  --muted: #8c989e;
}
html, body {
  height: 100%;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 50% 20%, #16303c 0%, var(--bg-top) 40%, var(--bg-bot) 100%);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
}
#board { position: fixed; inset: 0; width: 100%; height: 100%; display: none; }
body.in-game #board { display: block; }

/* Écrans */
.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.hidden { display: none !important; }

.panel {
  background: var(--panel);
  backdrop-filter: blur(6px);
  border: 1px solid #ffffff1a;
  border-radius: 20px;
  padding: 32px 36px;
  width: min(460px, 94vw);
  box-shadow: 0 20px 60px #0008;
  text-align: center;
}
.panel-wide { width: min(560px, 94vw); }

.logo {
  font-size: clamp(48px, 12vw, 84px);
  font-weight: 800; letter-spacing: 4px;
  text-shadow: 0 4px 0 #0006;
}
.tagline { color: var(--soft); margin: 6px 0 18px; }
h2 { font-size: 28px; margin-bottom: 16px; }

.demo-cards { display: flex; gap: 8px; justify-content: center; margin: 4px 0 22px; }
.demo-cards .dc {
  width: 46px; height: 64px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px; box-shadow: 0 3px 0 #0006;
}

.btn-col { display: flex; flex-direction: column; gap: 12px; }
.btn-row { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }
.btn {
  border: none; border-radius: 12px; padding: 12px 20px;
  font-size: 17px; font-weight: 700; color: var(--text);
  background: var(--panel-light); cursor: pointer;
  transition: transform .06s, background .15s, box-shadow .15s;
  box-shadow: 0 3px 0 #0005;
}
.btn:hover { background: #33505e; }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn-lg { padding: 16px; font-size: 19px; }
.btn-green { background: var(--green); }
.btn-green:hover { background: var(--green-h); }
.btn-blue { background: var(--blue); }
.btn-blue:hover { background: #3a72a3; }
.btn-ghost { background: #ffffff12; }
.btn-mini { padding: 7px 12px; font-size: 14px; }

.label { color: var(--muted); font-size: 14px; margin: 16px 0 8px; }
.seg { display: flex; gap: 8px; justify-content: center; }
.seg button {
  flex: 1; border: none; border-radius: 10px; padding: 12px;
  background: var(--panel-light); color: var(--text); font-size: 16px;
  font-weight: 700; cursor: pointer;
}
.seg button.on { background: var(--green); }

.input {
  width: 100%; border: 1px solid #ffffff22; border-radius: 10px;
  padding: 12px 14px; font-size: 16px; background: #0d1a22; color: var(--text);
  outline: none; margin-bottom: 4px;
}
.input:focus { border-color: var(--accent); }
.code-input { text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 800; }

.online-actions { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.join-row { display: flex; gap: 10px; }
.join-row .code-input { flex: 1; }
.hint { color: var(--muted); font-size: 14px; margin: 12px 0; min-height: 18px; }

/* Lobby */
.code-box {
  font-size: 20px; margin: 8px 0 18px; display: flex; align-items: center;
  justify-content: center; gap: 12px;
}
.code-box span { font-size: 34px; font-weight: 800; letter-spacing: 6px; color: var(--gold); }
.players { list-style: none; text-align: left; margin: 10px 0; }
.players li {
  display: flex; align-items: center; justify-content: space-between;
  background: #ffffff0e; border-radius: 10px; padding: 12px 16px; margin-bottom: 8px;
  font-size: 17px;
}
.players .tag { font-size: 13px; padding: 3px 9px; border-radius: 20px; font-weight: 700; }
.tag-ready { background: var(--green); }
.tag-wait { background: #6b5a20; color: var(--gold); }
.tag-bot { background: var(--blue); }
.tag-host { background: #7a3f9a; }
.players .rm { background: #a33; border: none; color: #fff; border-radius: 6px; cursor: pointer; padding: 3px 8px; }
.host-controls { margin: 12px 0; }
.add-bot { display: flex; gap: 10px; justify-content: center; }
.add-bot .input { width: auto; margin: 0; }
.mode-line { font-size: 16px; color: var(--soft); margin: -8px 0 10px; }
.mode-line b { color: var(--gold); }
.mode-seg { margin: 0 0 14px; }
.mode-note { margin-top: 8px; }

/* Overlays */
.overlay {
  position: fixed; inset: 0; background: #000a; z-index: 20;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.scores { width: 100%; border-collapse: collapse; margin: 10px 0 4px; }
.scores td { padding: 10px 8px; font-size: 18px; border-bottom: 1px solid #ffffff14; text-align: left; }
.scores td.num { text-align: right; font-weight: 800; }
.scores td.round { color: var(--gold); text-align: right; }
.scores tr.me td { color: var(--gold); }
.winner { font-size: 24px; font-weight: 800; color: var(--gold); margin: 8px 0 12px; }

.rules-text { text-align: left; color: var(--soft); font-size: 15px; line-height: 1.5; }
.rules-text p, .rules-text ul { margin-bottom: 10px; }
.rules-text ul { padding-left: 22px; }
.rules-text h2 { text-align: center; }
.legend { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.legend span { padding: 4px 10px; border-radius: 6px; font-weight: 700; color: #fff; }
.c-neg { background: #244a96; } .c-zero { background: #56aacd; color:#08202b !important; }
.c-low { background: #42a660; } .c-mid { background: #e6c24a; color:#2e2206 !important; }
.c-high { background: #d65c46; }

.corner-btn {
  position: fixed; top: 14px; right: 14px; z-index: 15;
  background: #0009; border: 1px solid #ffffff22; color: var(--text);
  border-radius: 10px; padding: 8px 14px; font-size: 14px; cursor: pointer;
}
.corner-btn:hover { background: #a33c; }

/* Contrôles de zoom (in-game) */
.zoom-controls {
  position: fixed; left: 14px; bottom: 14px; z-index: 15;
  display: flex; flex-direction: column; gap: 8px;
}
.zoom-controls button {
  width: 46px; height: 46px; border-radius: 12px; font-size: 22px; font-weight: 700;
  background: #0d1a22cc; border: 1px solid #ffffff2a; color: var(--text); cursor: pointer;
  line-height: 1; display: flex; align-items: center; justify-content: center;
}
.zoom-controls button:active { background: var(--green); }

/* Historique */
.hist-stats {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 6px 0 16px;
}
.hist-stats > div {
  background: #ffffff10; border-radius: 12px; padding: 12px 18px; min-width: 78px; text-align: center;
}
.hist-stats b { display: block; font-size: 26px; color: var(--gold); }
.hist-stats span { font-size: 12px; color: var(--muted); }
.hist-list { max-height: 46vh; overflow-y: auto; text-align: left; }
.hist-item { background: #ffffff0c; border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
.hist-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
.hist-scores { margin-top: 6px; font-size: 14px; color: var(--soft); line-height: 1.6; }
.hist-scores .you { color: var(--gold); font-weight: 700; }
.hb { font-size: 12px; padding: 3px 9px; border-radius: 20px; background: #ffffff18; font-weight: 700; color: var(--soft); }
.hb.win { background: var(--green); color: #fff; }

.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: #0d1a22; border: 1px solid var(--accent); color: var(--text);
  padding: 14px 22px; border-radius: 12px; z-index: 30; font-size: 16px;
  box-shadow: 0 10px 30px #0008; max-width: 90vw; text-align: center;
}
