/* ═══════════════════════════════════════════════════════════════
   carre_rouge_game.css
   Styles du jeu Carré Rouge — chargé après carre_rouge.css
   (carre_rouge.css gère body, h1, h2, h3, .rouge, .bleu, etc.)
═══════════════════════════════════════════════════════════════ */

/* ── Reset & tokens ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:      #DB0202;
  --red-dark: #820D21;
  --red-glow: rgba(219,2,2,0.55);
  --blue:     #000099;
  --blue-dim: rgba(0,0,153,0.10);
  --white:    #ffffff;
  --bg:       #0a0a1a;
  --panel:    #ffffff;
  --border:   #d4d4ea;
  --font:     'Roboto', sans-serif;
}

/* ── Base ── */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background-color: var(--bg);
  background-image: url('../images/carrerouge-fond.png');
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
  min-height: 100dvh;
}

/* ── Header ── */
#header {
  background-image: url('../images/carrerouge-top.png');
  background-repeat: repeat-x;
  background-size: auto 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  padding: 10px 16px;
}
#header img {
  display: block;
  max-width: min(100%, 640px);
  height: auto;
}

/* ── Bandeau pub ── */
.ad-banner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px 0;
  min-height: 50px;
  overflow: hidden;
}
.ad-banner ins,
.row-ad-bottom ins { max-width: 100% !important; }

/* ── Wrapper principal ── */
#main {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 10px 32px;
}

/* ── Panel blanc ── */
#panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 16px;
}

/* ── Table interne (outer-table / tbody) ── */
#outer-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
#outer-table td { vertical-align: top; }

.row-header td {
  padding: 16px 16px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.row-header h1 {
  font-size: clamp(14px, 3.5vw, 24px) !important;
  font-weight: 300 !important;
  color: var(--blue) !important;
  text-shadow: 0 0 1px #7786EF !important;
  line-height: 1.3 !important;
  margin: 0 !important;
}

.row-game .td-game {
  width: 60%;
  padding: 14px 14px 14px 16px;
}
.row-game .td-sidebar {
  width: 40%;
  padding: 14px 12px 14px 10px;
  border-left: 1px solid var(--border);
  text-align: center;
}

.row-comments td {
  padding: 20px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.row-ad-bottom td {
  padding: 8px 0 14px;
  border-top: 1px solid var(--border);
  text-align: center;
}

/* ── Colonne jeu ── */
.game-col {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* Score bar */
#score-bar {
  display: flex;
  gap: 6px;
}
.score-chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--blue);
  border-radius: 6px;
  padding: 5px 8px;
}
.score-chip .sc-label {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.5);
}
.score-chip .sc-value {
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 900;
  color: var(--white);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* Barre de difficulté */
#diff-bar {
  height: 3px;
  background: #e0e0f0;
  border-radius: 2px;
  overflow: hidden;
}
#diff-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--red));
  width: 0%;
  transition: width 0.6s ease;
}

/* ── Arène ── */
#arena-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
}
#arena {
  width: 100%;
  height: 100%;
  background: #06060f;
  background-image:
    linear-gradient(var(--blue-dim) 1px, transparent 1px),
    linear-gradient(90deg, var(--blue-dim) 1px, transparent 1px);
  background-size: 36px 36px;
  border: 2px solid var(--blue);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
#arena.danger {
  border-color: var(--red-dark);
  box-shadow: inset 0 0 18px rgba(130,13,33,0.2), 0 0 0 2px rgba(130,13,33,0.35);
}

/* Carré rouge */
#red-sq {
  position: absolute;
  background: var(--red);
  border: 1px solid #000;
  border-radius: 3px;
  box-shadow: 0 0 10px var(--red-glow);
  touch-action: none;
  will-change: transform;
  z-index: 10;
  cursor: grab;
}
#red-sq:active { cursor: grabbing; }
#red-sq.flash  { background: #ff5555; box-shadow: 0 0 22px rgba(255,80,80,0.95); }

/* Blocs ennemis */
.block {
  position: absolute;
  background: var(--blue);
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(0,0,200,0.55);
  will-change: transform;
  z-index: 5;
  pointer-events: none;
}

/* Overlay démarrage / game over */
#game-overlay {
  position: absolute; inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(4,4,18,0.88);
  border-radius: 4px;
  z-index: 50;
  gap: 11px;
  padding: 20px;
  text-align: center;
}
.overlay-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.overlay-sq {
  width: clamp(26px, 8vw, 42px);
  height: clamp(26px, 8vw, 42px);
  background: var(--red);
  border: 2px solid #000;
  border-radius: 4px;
  box-shadow: 0 0 14px var(--red-glow);
  animation: pulse-sq 1.8s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse-sq {
  0%,100% { box-shadow: 0 0 10px var(--red-glow); }
  50%      { box-shadow: 0 0 28px rgba(219,2,2,0.9); }
}
.overlay-title {
  font-size: clamp(18px, 6vw, 28px);
  font-weight: 900;
  color: var(--white);
  letter-spacing: -0.5px;
  text-shadow: 0 0 10px var(--red-glow);
}
.overlay-sub {
  font-size: clamp(11px, 2.8vw, 13px);
  font-weight: 300;
  color: rgba(170,170,210,0.85);
  line-height: 1.55;
  max-width: 200px;
}
.big-score {
  font-size: clamp(52px, 16vw, 82px);
  font-weight: 900;
  color: var(--white);
  line-height: 1;
  text-shadow: 0 0 20px var(--red-glow);
}
.score-label {
  font-size: clamp(9px, 2vw, 11px);
  font-weight: 300;
  color: rgba(170,170,210,0.65);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: -4px;
}
.best-line {
  font-size: clamp(12px, 3vw, 15px);
  font-weight: 700;
  color: rgba(200,200,255,0.85);
}
#btn-play {
  display: inline-block;
  padding: 12px 34px;
  background: var(--red);
  color: var(--white);
  border: 2px solid rgba(0,0,0,0.25);
  border-radius: 6px;
  font-family: var(--font);
  font-size: clamp(14px, 3.5vw, 16px);
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 18px var(--red-glow);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
#btn-play:hover  { background: var(--red-dark); box-shadow: 0 4px 26px rgba(130,13,33,0.75); }
#btn-play:active { transform: scale(0.95); }
.hint-controls {
  font-size: 10px;
  font-weight: 300;
  color: rgba(100,100,140,0.8);
  margin-top: -3px;
}

/* ── Sidebar ── */
.sidebar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.sidebar-col h2 {
  font-size: clamp(13px, 3vw, 19px) !important;
  line-height: 1.3 !important;
  margin-top: 0 !important;
  color: var(--red-dark) !important;
  text-shadow: 0 0 2px #DB0202 !important;
}
.sidebar-col h3 {
  font-size: clamp(11px, 2.3vw, 15px) !important;
  line-height: 1.5 !important;
  margin-top: 0 !important;
  color: var(--blue) !important;
}
.rules {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  text-align: left;
}
.rule {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}
.rule-icon {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  color: var(--white);
  margin-top: 1px;
}
.rule-icon.r { background: var(--red); }
.rule-icon.b { background: var(--blue); }
.rule-icon.s { background: #666; }
.rule-text {
  font-size: clamp(11px, 2vw, 13px);
  font-weight: 300;
  color: var(--blue);
  line-height: 1.45;
}

/* ── Footer ── */
#footer-strip {
  text-align: center;
  padding: 10px 16px 22px;
  font-size: 11px;
  font-weight: 300;
  color: rgba(255,255,255,0.28);
}
#footer-strip a { color: rgba(255,255,255,0.4); text-decoration: none; }

/* ── Mobile ≤ 640px ── */
@media (max-width: 640px) {
  body { background-attachment: scroll; }
  #panel { border-radius: 8px; margin-top: 10px; }
  #outer-table,
  #outer-table tbody,
  #outer-table tr,
  #outer-table td { display: block; width: 100% !important; }
  .row-header td { padding: 12px 12px 8px; }
  .row-game .td-game { padding: 10px 10px 6px; }
  .row-game .td-sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 12px 10px;
  }
  #arena-wrap { aspect-ratio: 1 / 0.88; }
  .rules { gap: 8px; }
  .row-comments td { padding: 14px 10px; }
}

/* ── Tablette 641–900px ── */
@media (min-width: 641px) and (max-width: 900px) {
  .row-game .td-game    { width: 58%; }
  .row-game .td-sidebar { width: 42%; }
  #arena-wrap { max-height: 52vw; }
}

/* ── Desktop > 900px ── */
@media (min-width: 901px) {
  #arena-wrap { max-height: 480px; }
}
