@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700;900&family=Crimson+Text:ital,wght@0,400;0,600;1,400&display=swap');
:root {
  --bg: #1a1008; --bg2: #221508; --gold: #c9993a; --gold-light: #e8c060;
  --gold-dark: #8b6820; --cream: #f5e6c8; --dark-text: #2a1a05;
  --cell-dark: #6b3a1f; --cell-light: #d4a96a; --piece-white: #f0e0b0;
  --piece-white-border: #c8a050; --piece-black: #1a1008; --piece-black-border: #4a3010;
  --shadow: 0 8px 32px rgba(0,0,0,0.6); --border-radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
button, .menu-card, .cell, .radio-card, .room-btn { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
html { scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }
body { background: var(--bg); font-family: 'Crimson Text', Georgia, serif; color: var(--cream); min-height: 100vh; background-image: radial-gradient(ellipse at 20% 20%, rgba(201,153,58,0.08) 0%, transparent 50%), radial-gradient(ellipse at 80% 80%, rgba(107,58,31,0.15) 0%, transparent 50%); }
.hidden { display: none !important; }
header { text-align: center; padding: 2rem 1rem 1rem; border-bottom: 1px solid rgba(201,153,58,0.3); }
header h1 { font-family: 'Cinzel', serif; font-size: clamp(1.8rem, 5vw, 3rem); font-weight: 900; color: var(--gold-light); letter-spacing: 0.08em; text-shadow: 0 2px 8px rgba(201,153,58,0.4); }
header p { font-style: italic; color: var(--gold-dark); font-size: 1rem; margin-top: 0.3rem; }
main { max-width: 900px; margin: 0 auto; padding: 2rem 1rem; }
.menu-container { display: flex; flex-direction: column; align-items: center; gap: 2rem; padding: 2rem 0; }
.menu-title { font-family: 'Cinzel', serif; font-size: 1.5rem; color: var(--gold); text-align: center; }
.menu-card { background: linear-gradient(135deg, rgba(34,21,8,0.95), rgba(42,26,10,0.95)); border: 1px solid rgba(201,153,58,0.3); border-radius: var(--border-radius); padding: 2rem; width: 100%; max-width: 440px; text-align: center; box-shadow: var(--shadow); cursor: pointer; transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s; }
.menu-card:hover { transform: translateY(-4px); border-color: var(--gold); box-shadow: 0 12px 40px rgba(201,153,58,0.25); }
.menu-card h2 { font-family: 'Cinzel', serif; font-size: 1.4rem; color: var(--gold-light); margin-bottom: 0.5rem; }
.menu-card p { color: rgba(245,230,200,0.7); font-size: 0.95rem; }
.menu-card .icon { font-size: 2.5rem; margin-bottom: 0.8rem; }
.btn { font-family: 'Cinzel', serif; font-size: 0.9rem; letter-spacing: 0.05em; padding: 0.65rem 1.5rem; border: none; border-radius: 8px; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 0.4rem; }
.btn-gold { background: linear-gradient(135deg, var(--gold-dark), var(--gold)); color: var(--dark-text); font-weight: 700; box-shadow: 0 2px 8px rgba(201,153,58,0.4); }
.btn-gold:hover { background: linear-gradient(135deg, var(--gold), var(--gold-light)); transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1px solid rgba(201,153,58,0.5); color: var(--gold); }
.btn-outline:hover { border-color: var(--gold); background: rgba(201,153,58,0.1); }
.btn-danger { background: rgba(180,40,40,0.7); color: var(--cream); border: 1px solid rgba(220,60,60,0.5); }
.btn-danger:hover { background: rgba(200,50,50,0.8); }
.game-wrapper { display: flex; flex-direction: column; align-items: center; gap: 1.2rem; }
.board-container { position: relative; padding: 12px; background: linear-gradient(135deg, #3d1f0a, #5c2f10); border-radius: 10px; box-shadow: 0 0 0 3px var(--gold-dark), 0 0 0 6px #2a1206, var(--shadow); }
.board { display: grid; grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(10, 1fr); width: min(540px, 92vw); height: min(540px, 92vw); border: 2px solid var(--gold-dark); }
.cell { display: flex; align-items: center; justify-content: center; cursor: default; transition: background-color 0.15s; position: relative; }
.cell.dark { background: var(--cell-dark); }
.cell.light { background: var(--cell-light); }
.cell.dark.has-move { cursor: pointer; }
.cell.selected { background: rgba(255,215,0,0.55) !important; }
.cell.target { background: rgba(100,220,100,0.45) !important; cursor: pointer; }
.cell.target::after { content: ''; width: 28%; height: 28%; border-radius: 50%; background: rgba(100,220,100,0.7); position: absolute; }
.piece { width: 76%; height: 76%; border-radius: 50%; position: relative; transition: transform 0.15s; }
.piece:hover { transform: scale(1.05); }
.piece-white { background: radial-gradient(circle at 35% 35%, #fff8e0, var(--piece-white) 60%, #c8a050); border: 2px solid var(--piece-white-border); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.2), inset 0 3px 6px rgba(255,255,255,0.6), 0 3px 8px rgba(0,0,0,0.4); }
.piece-black { background: radial-gradient(circle at 35% 35%, #4a3010, var(--piece-black) 60%, #0a0502); border: 2px solid var(--piece-black-border); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.5), inset 0 3px 6px rgba(100,70,20,0.3), 0 3px 8px rgba(0,0,0,0.5); }
.piece-king::after { content: '♛'; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 45%; line-height: 1; }
.piece-white.piece-king::after { color: var(--gold-dark); }
.piece-black.piece-king::after { color: var(--gold-light); }
.status { font-family: 'Cinzel', serif; font-size: 1rem; padding: 0.5rem 1.5rem; border-radius: 8px; background: rgba(34,21,8,0.8); border: 1px solid rgba(201,153,58,0.3); color: var(--cream); text-align: center; }
.status.winner { color: var(--gold-light); border-color: var(--gold); background: rgba(50,30,5,0.9); font-weight: 700; font-size: 1.1rem; }
.status.my-turn { color: #90ee90; border-color: rgba(144,238,144,0.4); }
.game-controls { display: flex; gap: 0.8rem; flex-wrap: wrap; justify-content: center; }
.online-container { max-width: 480px; margin: 0 auto; }
.section-title { font-family: 'Cinzel', serif; color: var(--gold); font-size: 1.1rem; margin-bottom: 1rem; padding-bottom: 0.4rem; border-bottom: 1px solid rgba(201,153,58,0.2); }
.input-group { display: flex; flex-direction: column; gap: 0.8rem; margin-bottom: 1.5rem; }
.input-group label { font-size: 0.9rem; color: rgba(245,230,200,0.7); }
.game-input { background: rgba(34,21,8,0.8); border: 1px solid rgba(201,153,58,0.4); border-radius: 8px; padding: 0.6rem 1rem; color: var(--cream); font-family: 'Crimson Text', serif; font-size: 1rem; width: 100%; transition: border-color 0.2s; }
.game-input:focus { outline: none; border-color: var(--gold); }
.action-row { display: flex; gap: 0.8rem; }
.action-row .btn { flex: 1; justify-content: center; }
.divider { text-align: center; color: rgba(201,153,58,0.5); margin: 1.2rem 0; font-size: 0.85rem; position: relative; }
.divider::before, .divider::after { content: ''; position: absolute; top: 50%; width: 40%; height: 1px; background: rgba(201,153,58,0.2); }
.divider::before { left: 0; } .divider::after { right: 0; }
.rooms-container { margin-top: 1rem; }
.room-btn { width: 100%; padding: 0.7rem 1rem; margin-bottom: 0.5rem; background: rgba(107,58,31,0.3); border: 1px solid rgba(201,153,58,0.3); border-radius: 8px; color: var(--cream); cursor: pointer; font-family: 'Crimson Text', serif; font-size: 1rem; transition: all 0.2s; text-align: left; }
.room-btn:hover { background: rgba(107,58,31,0.6); border-color: var(--gold); }
.no-rooms { color: rgba(245,230,200,0.4); font-style: italic; text-align: center; padding: 1rem; }
.waiting-card { background: rgba(34,21,8,0.9); border: 1px solid rgba(201,153,58,0.4); border-radius: var(--border-radius); padding: 2rem; text-align: center; }
.room-code { font-family: 'Cinzel', serif; font-size: 2.5rem; color: var(--gold-light); letter-spacing: 0.2em; margin: 1rem 0; background: rgba(0,0,0,0.3); padding: 0.5rem 1.5rem; border-radius: 8px; display: inline-block; }
.waiting-dots { color: var(--gold-dark); font-style: italic; margin-top: 1rem; }
.waiting-dots::after { content: '...'; animation: dots 1.5s infinite; }
@keyframes dots { 0%,33%{content:'.'} 34%,66%{content:'..'} 67%,100%{content:'...'} }
.online-info { display: flex; justify-content: space-between; align-items: center; width: min(540px, 92vw); font-size: 0.9rem; }
#my-color-label { font-family: 'Cinzel', serif; color: var(--gold); }
#opponent-name { color: rgba(245,230,200,0.7); }
footer { text-align: center; padding: 1.5rem 1rem 2rem; border-top: 1px solid rgba(201,153,58,0.15); margin-top: 2rem; color: rgba(245,230,200,0.4); font-size: 0.85rem; font-style: italic; }
.signature { font-family: 'Cinzel', serif; font-style: normal; font-weight: 700; color: var(--gold); letter-spacing: 0.1em; text-shadow: 0 0 12px rgba(201,153,58,0.4); }
.setup-container { max-width: 500px; margin: 0 auto; background: linear-gradient(135deg, rgba(34,21,8,0.95), rgba(42,26,10,0.95)); border: 1px solid rgba(201,153,58,0.3); border-radius: var(--border-radius); padding: 2rem; box-shadow: var(--shadow); }
.setup-group { margin-bottom: 1.8rem; }
.setup-label { font-family: 'Cinzel', serif; color: var(--gold); font-size: 0.95rem; margin-bottom: 0.8rem; }
.radio-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.7rem; }
.radio-group-2 { grid-template-columns: repeat(2, 1fr); max-width: 320px; }
.radio-card { display: flex; flex-direction: column; align-items: center; padding: 0.9rem 0.5rem; border: 1px solid rgba(201,153,58,0.25); border-radius: 10px; cursor: pointer; transition: all 0.2s; background: rgba(0,0,0,0.2); position: relative; }
.radio-card input { position: absolute; opacity: 0; pointer-events: none; }
.radio-card:has(input:checked) { border-color: var(--gold); background: rgba(201,153,58,0.15); box-shadow: 0 0 12px rgba(201,153,58,0.2); }
.radio-card:hover { border-color: rgba(201,153,58,0.6); }
.radio-icon { font-size: 1.6rem; margin-bottom: 0.3rem; }
.radio-title { font-family: 'Cinzel', serif; font-size: 0.85rem; color: var(--cream); }
.radio-desc { font-size: 0.75rem; color: rgba(245,230,200,0.5); margin-top: 0.15rem; }
.setup-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-top: 0.5rem; }
.ai-info-bar { display: flex; align-items: center; justify-content: space-between; width: min(540px, 92vw); gap: 1rem; }
.ai-label { font-family: 'Cinzel', serif; font-size: 0.9rem; color: var(--gold); white-space: nowrap; }
.thinking-status { color: #ffd27a; border-color: rgba(255,210,122,0.4); animation: pulse 1s infinite alternate; }
@keyframes pulse { from{opacity:0.7} to{opacity:1} }
.piece.thinking { animation: bounce 0.5s infinite alternate; }
@keyframes bounce { from{transform:translateY(0)} to{transform:translateY(-3px)} }
@media (max-width: 768px) {
  header { padding: 1.2rem 1rem 0.8rem; } header h1 { font-size: 1.8rem; }
  main { padding: 1.2rem 0.8rem; }
  .board { width: min(480px, 94vw); height: min(480px, 94vw); }
}
@media (max-width: 480px) {
  header { padding: 0.9rem 0.8rem 0.6rem; } header h1 { font-size: 1.35rem; }
  main { padding: 0.8rem 0.5rem; }
  .menu-card { padding: 1.1rem 1rem; display: flex; align-items: center; gap: 1rem; text-align: left; }
  .menu-card .icon { font-size: 1.8rem; margin-bottom: 0; flex-shrink: 0; }
  .menu-card h2 { font-size: 1rem; margin-bottom: 0.2rem; }
  .board-container { padding: 7px; }
  .board { width: min(370px, 97vw); height: min(370px, 97vw); }
  .piece { width: 80%; height: 80%; }
  .btn { font-size: 0.78rem; padding: 0.5rem 0.85rem; }
  .game-controls { gap: 0.5rem; }
  .online-info, .ai-info-bar { flex-direction: column; align-items: flex-start; gap: 0.3rem; width: 97vw; }
  .setup-container { padding: 1rem 0.8rem; }
  .radio-group { gap: 0.4rem; } .radio-group-2 { max-width: 100%; }
  .radio-card { padding: 0.6rem 0.3rem; } .radio-icon { font-size: 1.2rem; }
  .radio-title { font-size: 0.75rem; } .radio-desc { font-size: 0.65rem; }
  .action-row { flex-direction: column; }
  .room-code { font-size: 1.8rem; }
  footer { font-size: 0.78rem; padding: 1rem 0.8rem 1.5rem; }
}
@media (max-width: 360px) {
  header h1 { font-size: 1.15rem; }
  .board { width: 99vw; height: 99vw; }
  .board-container { padding: 5px; }
  .btn { font-size: 0.72rem; padding: 0.45rem 0.7rem; }
  .room-code { font-size: 1.5rem; }
}

/* ---- CHRONOMETRE ---- */
.timer-bar {
  display: flex;
  justify-content: space-between;
  width: min(540px, 92vw);
  gap: 1rem;
  margin-bottom: 0.3rem;
}
.timer-box {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.4rem 1.2rem;
  border-radius: 8px;
  background: rgba(34,21,8,0.8);
  border: 1px solid rgba(201,153,58,0.3);
  color: var(--cream);
  transition: all 0.3s;
  flex: 1;
  text-align: center;
}
.timer-active {
  border-color: var(--gold);
  color: var(--gold-light);
  box-shadow: 0 0 12px rgba(201,153,58,0.3);
  animation: pulse 1s infinite alternate;
}
.timer-danger {
  border-color: #ff4444 !important;
  color: #ff4444 !important;
  box-shadow: 0 0 12px rgba(255,68,68,0.4) !important;
  animation: pulse-danger 0.5s infinite alternate !important;
}
@keyframes pulse-danger {
  from { opacity: 0.7; background: rgba(100,0,0,0.3); }
  to   { opacity: 1;   background: rgba(180,0,0,0.4); }
}
@media (max-width: 480px) {
  .timer-box { font-size: 0.85rem; padding: 0.3rem 0.6rem; }
}

/* ---- POPUP TIMER ---- */
.timer-popup-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.timer-popup-card {
  background: linear-gradient(135deg, rgba(34,21,8,0.98), rgba(50,28,8,0.98));
  border: 1px solid rgba(201,153,58,0.5);
  border-radius: 16px;
  padding: 2rem 2.5rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
  max-width: 380px;
  width: 90vw;
}
.timer-popup-title {
  font-family: 'Cinzel', serif;
  color: var(--gold-light);
  font-size: 1.4rem;
  margin-bottom: 0.4rem;
}
.timer-popup-sub {
  color: rgba(245,230,200,0.6);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
.timer-choices {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}
.timer-choice-btn {
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.7rem 0.5rem;
  border: 1px solid rgba(201,153,58,0.4);
  border-radius: 8px;
  background: rgba(107,58,31,0.3);
  color: var(--cream);
  cursor: pointer;
  transition: all 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.timer-choice-btn:hover, .timer-choice-btn:active {
  background: rgba(201,153,58,0.25);
  border-color: var(--gold);
  color: var(--gold-light);
  transform: translateY(-2px);
}
.timer-no-limit {
  width: 100%;
  background: rgba(40,40,60,0.4);
  border-color: rgba(150,150,200,0.3);
  color: rgba(245,230,200,0.7);
  font-size: 0.85rem;
  padding: 0.6rem;
}
.timer-no-limit:hover {
  background: rgba(60,60,100,0.4);
  border-color: rgba(150,150,220,0.6);
  color: var(--cream);
}
@media (max-width: 400px) {
  .timer-popup-card { padding: 1.5rem 1rem; }
  .timer-choices { grid-template-columns: repeat(5, 1fr); gap: 0.3rem; }
  .timer-choice-btn { font-size: 0.75rem; padding: 0.6rem 0.3rem; }
  .timer-popup-title { font-size: 1.1rem; }
}
