:root {
  --bg: #f6efe4;
  --surface: #fffaf2;
  --surface-alt: #f0e4d2;
  --border: #d7c3a8;
  --text: #3a2318;
  --text-muted: #755645;
  --cocoa-dark: #4b2a1c;
  --cocoa-mid: #7a472e;
  --off-white: #F8E6C8;

  /* Couleurs officielles KAKAO */
  --p-terracotta: #C06137;
  --p-ochre: #C3A536;
  --p-green: #699577;
  --p-plum: #855D77;
  --season-red: #BC4432;

  --radius: 12px;
  --shadow: 0 4px 14px rgba(58, 35, 24, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

/* Topbar */
.topbar {
  background: var(--cocoa-dark);
  color: var(--off-white);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--p-terracotta);
  color: var(--off-white);
  font-weight: 800;
  font-size: 1.4rem;
  display: grid;
  place-items: center;
  border: 2px solid var(--off-white);
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 1px;
}

.brand .subtitle {
  font-weight: 400;
  font-size: 0.95rem;
  opacity: 0.85;
}

.version-tag {
  margin: 2px 0 0;
  font-size: 0.78rem;
  opacity: 0.75;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.phase-banner {
  background: rgba(248, 230, 200, 0.16);
  border: 1px solid rgba(248, 230, 200, 0.35);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
}

/* Main container */
#app {
  max-width: 1320px;
  margin: 20px auto;
  padding: 0 16px 40px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.card h2, .card h3 {
  margin-top: 0;
  margin-bottom: 10px;
  color: var(--cocoa-dark);
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.card-header-row h3 {
  margin: 0;
}

.muted {
  color: var(--text-muted);
}

/* Buttons */
.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 15px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--p-terracotta);
  color: #fff;
}

.btn-secondary {
  background: var(--off-white);
  color: var(--cocoa-dark);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--cocoa-mid);
  color: var(--cocoa-dark);
}

.btn-lg {
  padding: 12px 24px;
  font-size: 1rem;
}

.badge {
  display: inline-block;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--cocoa-dark);
}

.badge-season {
  background: #fbeae7;
  border-color: var(--season-red);
  color: var(--season-red);
}

/* Setup Screen */
.setup-card {
  max-width: 720px;
  margin: 30px auto;
  padding: 26px;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 18px 0;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 600;
  font-size: 0.9rem;
}

.form-group select,
.form-group input {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 0.95rem;
}

.player-names-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 16px 0 22px;
}

.player-name-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-alt);
  padding: 10px;
  border-radius: 8px;
  border-left: 5px solid var(--cocoa-mid);
}

.player-name-box input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.setup-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

/* Game Layout */
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  gap: 18px;
  align-items: start;
}

@media (max-width: 980px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
}

.board-column,
.side-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Time Track */
.time-track {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}

.time-cell {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 54px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.time-cell-num {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.time-tokens {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
}

.time-token {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.5px solid var(--off-white);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Action Board 5x5 */
.action-board {
  display: grid;
  grid-template-columns: 88px repeat(3, 1fr) 88px;
  grid-template-rows: 84px repeat(3, 108px) 84px;
  gap: 8px;
  background: #3d281e;
  padding: 12px;
  border-radius: 12px;
}

@media (max-width: 640px) {
  .action-board {
    grid-template-columns: 60px repeat(3, 1fr) 60px;
    grid-template-rows: 68px repeat(3, 88px) 68px;
    gap: 5px;
    padding: 8px;
  }
}

.board-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--off-white);
  font-size: 0.72rem;
  text-align: center;
  opacity: 0.75;
  border: 1px dashed rgba(248, 230, 200, 0.25);
  border-radius: 8px;
  padding: 4px;
}

.round-space {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  position: relative;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.round-space.clickable {
  cursor: pointer;
  border-color: var(--p-ochre);
  box-shadow: 0 0 0 2px rgba(195, 165, 54, 0.45);
}

.round-space.clickable:hover {
  transform: scale(1.03);
  background: #fff4dd;
}

.round-space.current-round {
  border-color: var(--season-red);
  box-shadow: 0 0 0 2px rgba(188, 68, 50, 0.4);
}

.round-space-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
}

.season-pill {
  padding: 1px 5px;
  border-radius: 999px;
  font-size: 0.68rem;
  color: #fff;
}

.season-printemps { background: #c86d8a; }
.season-ete { background: #d49b27; }
.season-automne { background: #9b5b34; }
.season-hiver { background: #4a89aa; }

.space-pawns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 28px;
}

.pawn-chip {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--off-white);
  color: #fff;
  font-weight: 800;
  font-size: 0.75rem;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.35);
}

.season-marker {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--season-red);
  border: 2px solid var(--off-white);
  display: inline-block;
}

.move-cost-hint {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--p-terracotta);
  background: #fdeee6;
  padding: 1px 6px;
  border-radius: 999px;
}

/* Action Tiles 3x3 */
.action-tile {
  background: var(--off-white);
  border: 2px solid #b89878;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.action-tile.aligned {
  border-color: var(--p-ochre);
  box-shadow: 0 0 0 3px rgba(195, 165, 54, 0.5);
  background: #fff8e8;
}

.action-tile.selectable {
  cursor: pointer;
  border-color: var(--p-terracotta);
  box-shadow: 0 0 0 3px rgba(192, 97, 55, 0.55);
}

.action-tile.selectable:hover {
  transform: translateY(-2px);
}

.action-tile-title {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--cocoa-dark);
}

.action-tile-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.action-tile-cost {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--cocoa-dark);
  color: var(--off-white);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
}

.action-markers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 18px;
}

.heart-marker {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.board-legend {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Turn Panel */
.turn-card {
  border-left: 5px solid var(--p-terracotta);
}

.turn-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.turn-header h3 {
  margin: 0;
}

.player-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid rgba(0,0,0,0.15);
}

.turn-instruction {
  margin: 4px 0 12px;
  font-size: 0.92rem;
}

.turn-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ChocoBot */
.chocobot-display {
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

/* Players list */
.players-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.player-row {
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 10px 12px;
  border-left: 5px solid transparent;
}

.player-row.active-row {
  background: #fff2de;
  box-shadow: inset 0 0 0 1.5px var(--p-terracotta);
}

.player-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.player-row-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.player-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.player-stats strong {
  color: var(--text);
}

/* Log */
.game-log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
}

.game-log li {
  padding: 6px 8px;
  background: var(--surface-alt);
  border-radius: 6px;
}

/* Game Over */
.gameover-card {
  max-width: 680px;
  margin: 30px auto;
  text-align: center;
}
