/* Page-specific styles */
/* Hide everything while auto-loading the tutorial so the lobby never flashes */
html.tutorial-loading body { visibility: hidden; }
html.tutorial-loading #tutorial-overlay,
html.tutorial-loading #tutorial-overlay * { visibility: visible; }
html.tutorial-loading { background: #1a3a00; }

/* ===== LOBBY COLORS ===== */
#lobby { flex-direction: column; align-items: center; overflow-y: auto; min-height: calc(100vh - 44px); padding: 0 20px 52px; background: linear-gradient(160deg, #f8faf2 0%, #edf2e0 100%); }
.lobby-hero img { width: 100%; max-width: 220px; height: auto; border-radius: 16px; box-shadow: 0 8px 32px rgba(98,181,23,0.2), 0 0 0 1px rgba(98,181,23,0.12); }
#lobby h1 { font-size: 42px; color: #62b517; letter-spacing: 2px; font-weight: 800; margin: 0; line-height: 1.1; }
#lobby .subtitle { font-size: 15px; color: #555; margin: 0; line-height: 1.55; }
.lobby-meta-item { background: #f0f7e6; border: 1px solid #a8c96a; color: #4a8c11; }
.lobby-tutorial-cta { background: linear-gradient(135deg, #62b517 0%, #4a8e10 100%); color: #fff; box-shadow: 0 4px 18px rgba(98,181,23,0.32); }
.lobby-tutorial-cta:hover { box-shadow: 0 6px 24px rgba(98,181,23,0.48); }
.lobby-section-head::before, .lobby-section-head::after { background: linear-gradient(to right, transparent, rgba(98,181,23,0.35), transparent); }
.lobby-section-label { color: #62b517; }
.lo-strip { border: 1px solid #dde8c8; background: #fff; }
.lo-item { background: #fff; border-right: 1px solid #edf2e4; }
.lo-item-icon { background: #f4fae8; border: 1.5px solid #a8c96a; color: #62b517; }
.lo-item-title { color: #2a3a10; }
.lo-item-desc { color: #777; }
.lobby-card { background: #fff; border: 1.5px solid #dde8c8; box-shadow: 0 2px 16px rgba(98,181,23,0.08); }
.lobby-card h3 { color: #4a8c11; }
.lobby-card .card-desc { color: #888; }
@keyframes invitedPulse { 0%,100% { box-shadow: 0 0 0 2px rgba(98,181,23,0.45), 0 0 22px rgba(98,181,23,0.18), 0 4px 16px rgba(98,181,23,0.1); } 50% { box-shadow: 0 0 0 2px rgba(98,181,23,0.75), 0 0 38px rgba(98,181,23,0.32), 0 4px 16px rgba(98,181,23,0.18); } }
.lobby-card.lobby-card-focus { border-color: #62b517; background: linear-gradient(180deg, #f0fae4 0%, #fff 100%); animation: invitedPulse 2.6s ease-in-out infinite; }
.lobby-card.lobby-card-focus::before { background: #62b517; box-shadow: 0 4px 12px rgba(98,181,23,0.4); }
.invited-banner { background: linear-gradient(135deg, rgba(98,181,23,0.1) 0%, rgba(209,219,36,0.06) 100%); border: 1.5px solid rgba(98,181,23,0.4); box-shadow: 0 4px 16px rgba(98,181,23,0.12); }
.invited-banner-icon { background: rgba(98,181,23,0.12); border: 1px solid rgba(98,181,23,0.35); color: #4a8c11; }
.invited-banner-title { color: #2a3a10; }
.invited-banner-sub { color: #777; }
.invited-banner-code { color: #4a8c11; }
.invited-banner-arrow { color: #62b517; }
.color-btn.selected { border-color: #d1db24; box-shadow: 0 0 0 3px rgba(209,219,36,0.3); }
.btn-create { background: #62b517; color: white; }
.btn-join { background: #f0f7e6; color: #4a8c11; border: 1.5px solid #a8c96a; }
.btn-join:hover:not(:disabled) { background: #e2f3cc; border-color: #62b517; }
.lobby-input { background: #f8f7f4; border-color: #ccc; color: #333; }
.lobby-input::placeholder { color: #aaa; }
.lobby-input:focus { border-color: #62b517; }
.role-section-label { color: #888; }
.role-section-label::after { background: #e3e7d6; }
.player-role-box { border-color: #dde8c8; }
.player-role-box.active { border-color: #62b517; background: #fafdf2; }
.player-role-box .role-title { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: #62b517; margin-bottom: 6px; }
.observer-role-btn { background: #f8faf2; border-color: #dde8c8; color: #777; }
.observer-role-btn:hover:not(:disabled) { border-color: #22d3ee; color: #0e7490; background: #ecfeff; }
.observer-role-btn.selected { border-color: #22d3ee; background: #ecfeff; color: #0e7490; box-shadow: 0 0 0 1px rgba(34,211,238,0.25), inset 0 0 12px rgba(34,211,238,0.08); }
.obs-role-sub { color: #999; }
.observer-role-btn.selected .obs-role-sub { color: #0891b2; }
.obs-role-check { border-color: #cfd6c0; }
.observer-role-btn.selected .obs-role-check { border-color: #22d3ee; background: #22d3ee; box-shadow: 0 0 8px rgba(34,211,238,0.4); }
.obs-eye-icon { color: #22d3ee; filter: drop-shadow(0 0 3px rgba(34,211,238,0.45)); }
#observer-banner { background: linear-gradient(180deg, rgba(207,250,254,0.96), rgba(186,230,253,0.96)); border-bottom: 2px solid #22d3ee; box-shadow: 0 2px 10px rgba(34,211,238,0.2); color: #0e7490; }
#observer-banner .obs-pill { background: rgba(34,211,238,0.15); border: 1px solid rgba(34,211,238,0.5); color: #0e7490; }
body.observer-active { padding-top: calc(44px + 36px + 4px); }
body.observer-active #game { height: calc(100vh - 44px - 36px - 4px); }
.waiting-observer-section { max-width: 320px; }
.waiting-observer-label { color: #0891b2; }
.waiting-observer-row { background: #ecfeff; border-color: rgba(34,211,238,0.3); }
.waiting-observer-row .obs-name { color: #0e7490; }
.rules-banner { color: #555; background: #f4fae8; border-color: #dde8c8; }
.rules-banner a { color: #62b517; }
.error-msg { color: #d44; }
@media (max-width: 780px) {
  .lobby-hero img { max-width: 200px; margin: 0 auto; }
  .lobby-meta { justify-content: center; }
  #lobby h1 { font-size: 34px; }
  .lo-item:nth-child(1), .lo-item:nth-child(2) { border-bottom: 1px solid #edf2e4; }
}
@media (max-width: 480px) {
  #lobby h1 { font-size: 28px; }
}

/* ===== EVENT HUB ===== */
.event-hub-card { width: 100%; background: #fff; border: 1.5px solid #dde8c8; border-radius: 14px; padding: 20px 24px 22px; box-shadow: 0 2px 16px rgba(98,181,23,0.08); }
.event-hub-card h3 { font-size: 13px; color: #4a8c11; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 1px; font-weight: 800; }
.event-hub-add { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.event-hub-add button { flex-shrink: 0; padding: 9px 18px; background: #f0f7e6; border: 1.5px solid #a8c96a; border-radius: 8px; color: #4a8c11; font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.15s; white-space: nowrap; font-family: inherit; }
.event-hub-add button:hover:not(:disabled) { background: #e2f3cc; border-color: #62b517; color: #2d6309; }
.event-hub-empty { font-size: 12px; color: #999; padding: 16px 0 4px; text-align: center; font-style: italic; }
.event-table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 13px; }
.event-table th { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: #9aad7a; padding: 4px 10px 8px; text-align: left; border-bottom: 1px solid #e8f0d4; }
.event-table td { padding: 9px 10px; border-bottom: 1px solid #edf2e4; vertical-align: middle; }
.event-table tr:last-child td { border-bottom: none; }
.ev-code { font-size: 17px; font-weight: 800; letter-spacing: 3px; color: #4a8c11; font-family: monospace; }
.ev-copy-btn { background: #f4fae8; border: 1px solid #c8dda0; border-radius: 6px; padding: 3px 10px; font-size: 11px; font-weight: 700; color: #4a8c11; cursor: pointer; transition: all 0.12s; white-space: nowrap; font-family: inherit; }
.ev-copy-btn:hover { border-color: #62b517; background: #e2f3cc; }
.ev-copy-btn.copied { color: #62b517; border-color: #a8c96a; background: #e2f3cc; }
.ev-observe-btn { background: #f4fae8; border: 1px solid #a8c96a; border-radius: 6px; padding: 3px 10px; font-size: 11px; font-weight: 700; color: #4a8c11; cursor: pointer; transition: all 0.12s; white-space: nowrap; font-family: inherit; }
.ev-observe-btn:hover { border-color: #62b517; background: #e2f3cc; color: #2d6a0a; }
.ev-players { color: #888; font-size: 13px; }
.ev-status { display: inline-block; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.8px; border-radius: 3px; padding: 2px 7px; }
.ev-status.pending     { background: rgba(107,114,128,0.08); border: 1px solid rgba(107,114,128,0.25); color: #888; }
.ev-status.in-progress { background: rgba(98,181,23,0.10); border: 1px solid rgba(98,181,23,0.35); color: #4a8c11; }
.ev-status.completed   { background: rgba(74,140,17,0.10); border: 1px solid rgba(74,140,17,0.3); color: #2d6309; }
.ev-status.cancelled   { background: rgba(239,68,68,0.06); border: 1px solid rgba(239,68,68,0.25); color: #c0392b; }

/* ===== ROLE SELECTION (Player / Observer) ===== */
.role-section-label { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; color: #888; margin: 12px 0 6px; display: flex; align-items: center; gap: 8px; }
.role-section-label::after { content: ''; flex: 1; height: 1px; background: #e3e7d6; }
.player-role-box { border: 2px solid #dde8c8; border-radius: 10px; padding: 10px 14px; cursor: pointer; transition: all 0.15s; margin-bottom: 8px; }
.player-role-box.active { border-color: #62b517; background: #fafdf2; }
.player-role-box .role-title { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: #62b517; margin-bottom: 6px; }
.observer-role-btn { width: 100%; padding: 11px 14px; background: #f8faf2; border: 2px solid #dde8c8; border-radius: 10px; color: #777; cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: 10px; transition: all 0.15s; font-family: inherit; }
.observer-role-btn:hover:not(:disabled) { border-color: #22d3ee; color: #0e7490; background: #ecfeff; }
.observer-role-btn.selected { border-color: #22d3ee; background: #ecfeff; color: #0e7490; box-shadow: 0 0 0 1px rgba(34,211,238,0.25), inset 0 0 12px rgba(34,211,238,0.08); }
.observer-role-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.obs-role-icon { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.obs-role-text { display: flex; flex-direction: column; gap: 1px; text-align: left; }
.obs-role-title { font-size: 13px; font-weight: 700; }
.obs-role-sub { font-size: 10px; font-weight: 400; color: #999; line-height: 1.3; }
.observer-role-btn.selected .obs-role-sub { color: #0891b2; }
.obs-role-check { margin-left: auto; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #cfd6c0; flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.observer-role-btn.selected .obs-role-check { border-color: #22d3ee; background: #22d3ee; box-shadow: 0 0 8px rgba(34,211,238,0.4); }

/* ===== OBSERVER MODE. Eye icon ===== */
.obs-eye-icon { display: inline-block; width: 18px; height: 18px; color: #22d3ee; vertical-align: middle; filter: drop-shadow(0 0 3px rgba(34,211,238,0.45)); flex-shrink: 0; }
.obs-eye-icon.obs-eye-lg { width: 22px; height: 22px; }
.obs-eye-icon.obs-eye-xl { width: 26px; height: 26px; }
.obs-eye-icon.obs-eye-sm { width: 14px; height: 14px; }
@keyframes obs-eye-pulse { 0%,100% { filter: drop-shadow(0 0 4px rgba(34,211,238,0.4)); } 50% { filter: drop-shadow(0 0 8px rgba(34,211,238,0.85)); } }
.obs-eye-icon.obs-eye-pulse { animation: obs-eye-pulse 2.4s ease-in-out infinite; }

/* ===== OBSERVER BANNER (game screen) ===== */
#observer-banner { display: none; position: fixed; top: 44px; left: 0; right: 0; z-index: 99; background: linear-gradient(180deg, rgba(207,250,254,0.96), rgba(186,230,253,0.96)); border-bottom: 2px solid #22d3ee; box-shadow: 0 2px 10px rgba(34,211,238,0.2); padding: 6px 16px; align-items: center; gap: 10px; font-size: 12px; font-weight: 700; color: #0e7490; letter-spacing: 0.8px; text-transform: uppercase; }
#observer-banner .obs-pill { background: rgba(34,211,238,0.15); border: 1px solid rgba(34,211,238,0.5); border-radius: 20px; padding: 2px 10px; font-size: 11px; font-weight: 700; color: #0e7490; letter-spacing: 0.5px; text-transform: none; }
body.observer-active { padding-top: calc(44px + 36px + 4px); }
body.observer-active #game { height: calc(100vh - 44px - 36px - 4px); }

/* ===== WAITING ROOM. Observer section ===== */
.waiting-observer-section { width: 100%; max-width: 320px; margin-top: 8px; }
.waiting-observer-label { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; color: #0891b2; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.waiting-observer-row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: #ecfeff; border-radius: 8px; border: 1px solid rgba(34,211,238,0.3); margin-bottom: 5px; }
.waiting-observer-row .obs-name { font-size: 14px; color: #0e7490; flex: 1; font-weight: 600; }
.waiting-observer-row .host-badge, .obs-host-badge { font-size: 10px; color: #c90; font-weight: 700; }

/* ===== WAITING ROOM ===== */
#waiting { flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; gap: 20px; background: linear-gradient(160deg, #f8faf2 0%, #edf2e0 100%); }
.room-code-display { font-size: 52px; font-weight: 800; letter-spacing: 12px; color: #62b517; background: #fff; padding: 16px 36px; border-radius: 14px; border: 2px solid #a8c96a; user-select: all; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.room-share { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.copy-btn { padding: 8px 16px; font-size: 13px; font-weight: 700; border: 1px solid #a8c96a; border-radius: 8px; background: #fff; color: #62b517; cursor: pointer; transition: all 0.15s; }
.copy-btn:hover { background: #f4fae8; border-color: #62b517; }
.copy-btn.copied { background: #62b517; color: #fff; }
.room-hint { font-size: 14px; color: #888; }
.player-list { display: flex; flex-direction: column; gap: 8px; min-width: 240px; margin: 8px 0; }
.player-slot { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: #fff; border-radius: 8px; border: 1px solid #ddd; font-size: 15px; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.player-slot .dot { width: 14px; height: 14px; border-radius: 50%; }
.player-slot .host-badge { font-size: 11px; color: #c90; margin-left: auto; font-weight: 700; }
.player-slot .bot-badge { font-size: 10px; background: #555; color: #fff; font-weight: 700; padding: 1px 5px; border-radius: 4px; margin-left: 4px; }
.bot-toggle { padding: 10px 20px; font-size: 14px; font-weight: 600; border: 2px dashed #aaa; border-radius: 8px; background: transparent; color: #666; cursor: pointer; transition: all 0.15s; min-width: 240px; }
.bot-toggle:hover { border-color: #62b517; color: #62b517; background: #f4fae8; }
.bot-toggle.active { border-color: #62b517; border-style: solid; color: #62b517; background: #f4fae8; }
.waiting-actions { display: flex; gap: 10px; }
.waiting-actions button { padding: 12px 28px; border-radius: 8px; border: none; cursor: pointer; font-size: 15px; font-weight: 700; }
#btn-start-game { background: #62b517; color: white; }
#btn-start-game:disabled { opacity: 0.4; cursor: not-allowed; }
#btn-leave { background: #dde8c8; color: #777; }
#btn-leave:hover { background: #d0cdc6; color: #555; }

/* ===== GAME SCREEN ===== */
#game { flex-direction: column; height: calc(100vh - 44px); background: #e8edd8; overflow: hidden; }
#top-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; background: #fff; border-bottom: 2px solid #dde8c8; gap: 12px; flex-wrap: wrap; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
#top-bar .player-info { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: #444; }
.player-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
#top-bar .round-info { font-size: 13px; color: #888; font-weight: 600; }
.room-badge { font-size: 12px; color: #999; background: #f4fae8; padding: 3px 10px; border-radius: 6px; font-weight: 700; }
.view-toggle { display: flex; gap: 4px; }
.view-btn { padding: 5px 12px; font-size: 12px; border-radius: 6px; border: 2px solid #ddd; background: #fff; color: #888; cursor: pointer; position: relative; transition: all 0.15s; font-weight: 600; }
.view-btn:hover { background: #f4fae8; color: #555; }
.view-btn.active { border-color: #62b517; color: #62b517; background: #f4fae8; }
.view-btn .vb-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; vertical-align: middle; }
.view-btn.is-turn { box-shadow: 0 0 8px rgba(98,181,23,0.25); }
.node-circle.backprop-src { stroke: #f5a623; stroke-width: 3; stroke-dasharray: 6,3; cursor: pointer; }
.node-circle.backprop-dst { stroke: #62b517; stroke-width: 3; stroke-dasharray: 6,3; cursor: pointer; }
.first-badge { font-size: 10px; background: #f5a623; color: #fff; font-weight: 700; padding: 1px 5px; border-radius: 4px; margin-left: 4px; vertical-align: middle; letter-spacing: 0.3px; }
.tie-mark { font-size: 9px; background: #f5a623; color: #fff; font-weight: 700; padding: 0 3px; border-radius: 3px; margin-left: 2px; vertical-align: middle; }
.view-btn.is-turn::after { content: '◀'; font-size: 8px; margin-left: 4px; vertical-align: middle; }
.actions-info { font-size: 14px; color: #777; }
.actions-count { color: #62b517; font-weight: 800; font-size: 16px; }

/* Cancel Game */
.cancel-game-btn { padding: 5px 12px; font-size: 12px; font-weight: 700; border: 1.5px solid #e57373; border-radius: 7px; background: transparent; color: #e57373; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.cancel-game-btn:hover { background: #e57373; color: #fff; }

/* Cancel confirmation modal */
.cancel-modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; align-items: center; justify-content: center; }
.cancel-modal-overlay.open { display: flex; }
.cancel-modal { background: #fff; border-radius: 14px; padding: 28px 32px; max-width: 380px; width: 90%; box-shadow: 0 16px 48px rgba(0,0,0,0.2); text-align: center; }
.cancel-modal h3 { font-size: 18px; font-weight: 800; color: #2a2a2a; margin-bottom: 10px; }
.cancel-modal p { font-size: 14px; color: #666; line-height: 1.5; margin-bottom: 22px; }
.cancel-modal-actions { display: flex; gap: 10px; justify-content: center; }
.cancel-modal-actions .btn-yes { padding: 10px 28px; background: #e57373; color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer; transition: background 0.15s; }
.cancel-modal-actions .btn-yes:hover { background: #c62828; }
.cancel-modal-actions .btn-no { padding: 10px 28px; background: #f4fae8; color: #555; border: none; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer; transition: background 0.15s; }
.cancel-modal-actions .btn-no:hover { background: #dde8c8; }

#main-area { display: flex; flex: 1; overflow: hidden; }
#board-container { flex: 1; display: flex; align-items: center; justify-content: center; padding: 10px; background: #e8edd8; }
#board-svg { width: 100%; max-width: 860px; height: auto; }

#side-panel { width: 310px; min-width: 280px; display: flex; flex-direction: column; gap: 6px; padding: 10px; background: #fff; border-left: 2px solid #dde8c8; overflow-y: auto; }
.section-title { font-size: 11px; color: #999; text-transform: uppercase; letter-spacing: 1px; padding: 2px 0; font-weight: 700; }

/* ===== ACTION BUTTONS ===== */
.action-btns { display: flex; flex-direction: column; gap: 6px; }
.action-btn { padding: 8px 14px; font-size: 14px; border: 2px solid #ddd; border-radius: 8px; background: #f4fae8; color: #555; cursor: pointer; text-align: left; transition: all 0.15s; font-weight: 600; }
.action-btn:hover:not(:disabled) { border-color: #62b517; color: #62b517; background: #f4fae8; }
.action-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.end-turn-btn { padding: 8px 14px; font-size: 13px; border: 2px solid #ddd; border-radius: 8px; background: #f4fae8; color: #888; cursor: pointer; text-align: center; margin-top: 4px; font-weight: 600; }
.end-turn-btn:hover { border-color: #c90; color: #a80; }

/* ===== STATUS BAR ===== */
#status { padding: 8px 16px; min-height: 40px; background: #fff; border-top: 2px solid #dde8c8; font-size: 13px; color: #666; display: flex; align-items: center; gap: 10px; }
#status .msg { flex: 1; }
#status button { padding: 5px 16px; border-radius: 6px; border: 1px solid #ccc; background: #f4fae8; color: #555; cursor: pointer; font-size: 12px; white-space: nowrap; font-weight: 600; }
#status button:hover { border-color: #62b517; color: #62b517; }
#status button.primary { background: #62b517; border-color: #62b517; color: white; }
#status button.danger { background: #d44; border-color: #d44; color: white; }

/* ===== DICE ===== */
.dice-area { display: flex; gap: 8px; justify-content: center; padding: 6px 0; }
.die { width: 44px; height: 44px; background: #fff; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: bold; color: #333; cursor: default; transition: all 0.15s; border: 3px solid #ddd; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.die.clickable { cursor: pointer; border-color: #62b517; }
.die.clickable:hover { transform: scale(1.1); }
.die.selected { border-color: #d44; background: #fef0f0; }

/* ===== CLEAN DATA TRACKER ===== */
.clean-tracker { display: flex; gap: 4px; align-items: center; justify-content: center; padding: 4px 0; }
.clean-step { width: 34px; height: 26px; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: bold; background: #f4fae8; border: 1px solid #ddd; color: #aaa; }
.clean-step.active { background: #fce4d6; border-color: #e8a87c; color: #c07040; }
.clean-step.used { background: #f0e0e0; border-color: #d4a0a0; color: #a06060; }

/* ===== SCOREBOARD ===== */
.scoreboard { background: #f4fae8; border-radius: 10px; padding: 8px; flex-shrink: 0; border: 1px solid #e8e4dc; }
.score-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.score-table th { text-align: left; padding: 3px 5px; color: #999; font-weight: 600; border-bottom: 1px solid #e8e4dc; }
.score-table td { padding: 3px 5px; border-bottom: 1px solid #f4fae8; }
.score-table .score-val { text-align: center; font-weight: bold; }
.score-animal { font-size: 16px; }

/* ===== SVG STYLES ===== */
.edge-line { stroke: #c8c4ba; stroke-width: 2; transition: all 0.2s; }
.edge-line.blocked { stroke: #222; stroke-width: 3; stroke-dasharray: 8,4; }
.edge-line.path-highlight { stroke: #62b517; stroke-width: 4; opacity: 0.9; }
.edge-line.selectable { stroke: #e8a030; stroke-width: 3; opacity: 0.8; cursor: pointer; }

.node-circle { fill: #e8e4dc; stroke: #bbb; stroke-width: 2; transition: all 0.2s; cursor: default; }
.node-circle.placed { fill: #d0d8cf; stroke: #7a9a78; }
.node-circle.maxed { fill: #fce4b8; stroke: #d4a030; stroke-width: 3; }
.node-circle.clickable { cursor: pointer; stroke: #62b517; stroke-width: 3; stroke-dasharray: 6,3; }
.node-circle.clickable:hover { fill: #e2f0c8; }
.node-circle.path-selected { fill: #cce8a8; stroke: #62b517; stroke-width: 3; }

.node-data { font-size: 16px; font-weight: bold; fill: #62b517; pointer-events: none; }
.node-label { font-size: 11px; fill: #999; pointer-events: none; }
.input-label, .output-label { font-size: 14px; fill: #666; cursor: default; }
.input-emoji, .output-emoji { font-size: 24px; cursor: default; }
.input-label.clickable, .input-emoji.clickable { cursor: pointer; }
.input-label.clickable:hover, .input-emoji.clickable:hover { fill: #62b517; }
.input-label.highlight, .input-emoji.highlight { fill: #62b517; }
.overfit-x { stroke: #333; stroke-width: 3; pointer-events: none; }

/* ===== GAME OVER ===== */
#gameover { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); z-index: 100; flex-direction: column; align-items: center; justify-content: center; gap: 20px; overflow-y: auto; padding: 20px 0; }
#gameover h2 { font-size: 36px; color: #62b517; font-weight: 800; flex-shrink: 0; }
.final-scores { background: #fff; border-radius: 12px; padding: 20px; min-width: 340px; max-width: 580px; width: 90vw; box-shadow: 0 4px 24px rgba(0,0,0,0.15); }
/* Section titles inside final-scores */
.go-section-title { font-size: 11px; font-weight: 700; color: #999; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
/* Animal race scoreboard */
.go-scoreboard { background: #f8faf2; border-radius: 8px; padding: 8px 6px; margin-bottom: 4px; overflow-x: auto; }
.go-sb-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.go-sb-table th { padding: 3px 8px; text-align: center; color: #888; font-weight: 600; border-bottom: 1px solid #e8e4dc; }
.go-sb-table td { padding: 4px 8px; border-bottom: 1px solid #f4fae8; }
.go-sb-animal { white-space: nowrap; font-weight: 600; color: #444; text-align: left !important; }
.go-sb-entry { text-align: center; white-space: nowrap; }
/* Player rankings table */
.go-rank-table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.go-rank-table th, .go-rank-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #e8e4dc; color: #444; }
.go-rank-table .winner td { color: #b8860b; font-weight: bold; }
/* Breakdown / details */
.breakdown-toggle { font-size: 11px; padding: 3px 8px; border: 1px solid #ccc; border-radius: 6px; background: #f8faf2; cursor: pointer; color: #555; white-space: nowrap; }
.breakdown-toggle:hover { background: #edf2e0; }
.score-breakdown { background: #f8faf2; border-radius: 8px; padding: 10px 12px; font-size: 13px; color: #555; }
.breakdown-item { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed #e0dbd3; }
.breakdown-item:last-child { border-bottom: none; }
.breakdown-item.penalty { color: #c44; }
.breakdown-item.bonus { color: #62b517; }
.breakdown-total { display: flex; justify-content: space-between; padding: 6px 0 2px; font-weight: 700; color: #333; margin-top: 4px; border-top: 1px solid #ccc; }
/* Mini board inside details */
.go-mini-board { margin-top: 10px; border-top: 1px dashed #e0dbd3; padding-top: 8px; }
.go-mini-board-label { font-size: 11px; font-weight: 700; color: #999; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.go-mini-board-svg { width: 100%; height: auto; display: block; background: #e8edd8; border-radius: 6px; border: 1px solid #e0dbd3; }
#play-again-btn { padding: 12px 36px; font-size: 16px; border: none; border-radius: 8px; background: #62b517; color: white; cursor: pointer; font-weight: 700; flex-shrink: 0; }
.go-upsell { background: #fff; border-radius: 12px; padding: 16px 24px; min-width: 340px; max-width: 580px; width: 90vw; text-align: center; box-shadow: 0 4px 24px rgba(0,0,0,0.15); flex-shrink: 0; }
.go-upsell p { font-size: 14px; color: #4a8c11; margin: 0 0 10px; font-weight: 600; }
.go-upsell a { display: inline-block; background: #d1db24; color: #0f172a; text-decoration: none; padding: 10px 24px; border-radius: 8px; font-size: 14px; font-weight: 800; }
.go-upsell a:hover { filter: brightness(1.08); }

/* ===== INFO SYSTEM ===== */
.info-btn { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid #bbb; background: transparent; color: #999; font-size: 11px; font-weight: 700; cursor: pointer; margin-left: 5px; vertical-align: middle; transition: all 0.15s; font-family: serif; line-height: 1; padding: 0; }
.info-btn:hover { border-color: #62b517; color: #62b517; background: #f4fae8; }
#info-overlay { display: none; position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.3); backdrop-filter: blur(2px); }
#info-overlay.visible { display: flex; align-items: center; justify-content: center; }
#info-card { background: #fff; border-radius: 14px; padding: 20px 24px; max-width: 400px; width: 90%; box-shadow: 0 8px 32px rgba(0,0,0,0.18); position: relative; max-height: 80vh; overflow-y: auto; }
#info-card h3 { font-size: 16px; color: #62b517; margin-bottom: 10px; padding-right: 28px; }
#info-card p { font-size: 13px; color: #555; line-height: 1.6; margin-bottom: 8px; }
#info-card ul { font-size: 13px; color: #555; line-height: 1.6; padding-left: 18px; margin-bottom: 8px; }
#info-card li { margin-bottom: 4px; }
#info-card .info-close { position: absolute; top: 12px; right: 14px; width: 26px; height: 26px; border-radius: 50%; border: none; background: #f4fae8; color: #888; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
#info-card .info-close:hover { background: #dde8c8; color: #555; }
#info-card .info-highlight { background: #f4fae8; border-radius: 6px; padding: 8px 12px; margin: 8px 0; font-size: 12px; color: #62b517; border-left: 3px solid #62b517; }
.section-title .info-btn { margin-left: 4px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 860px) {
  .lobby-card { width: calc(100vw - 40px); max-width: 360px; }
  .rules-banner { max-width: calc(100vw - 40px); }
}

@media (max-width: 768px) {
  /* Lobby */
  #lobby h1 { font-size: 34px; }

  /* Game. Stack board above side panel, allow page scroll */
  #game { height: auto; min-height: calc(100dvh - 44px); overflow: visible; }
  #main-area { flex-direction: column; overflow: visible; height: auto; }
  #board-container { flex: none; height: 44vw; min-height: 220px; max-height: 46vh; overflow: hidden; padding: 6px; }
  #board-svg { width: 100%; height: 100%; }
  #side-panel {
    width: 100%; min-width: unset; border-left: none;
    border-top: 2px solid #dde8c8; overflow: visible;
    flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 8px; padding: 10px 12px;
  }
  #side-panel .section-title { width: 100%; margin-bottom: 0; }
  .action-btns { flex-direction: row; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 200px; }
  .action-btn { flex: 1; min-width: 130px; text-align: center; font-size: 13px; }
  .end-turn-btn { width: 100%; font-size: 12px; margin-top: 4px; }
  .scoreboard { flex: 1; min-width: 180px; }
  .dice-area { flex-wrap: nowrap; }

  /* Top bar */
  #top-bar { padding: 6px 12px; gap: 8px; }
  #top-bar .player-info { font-size: 13px; }
  .actions-info { font-size: 13px; }
  .actions-count { font-size: 14px; }

  /* Status bar */
  #status { padding: 6px 12px; font-size: 12px; }
}

@media (max-width: 480px) {
  /* Lobby */
  #lobby h1 { font-size: 28px; }
  .room-code-display { font-size: 38px; letter-spacing: 8px; padding: 12px 24px; }
  #waiting h2 { font-size: 20px; }

  /* Top bar */
  #top-bar { padding: 5px 10px; gap: 6px; }
  #top-bar .player-info { font-size: 12px; }
  .view-btn { padding: 4px 8px; font-size: 11px; }
  .room-badge { font-size: 11px; padding: 2px 7px; }

  /* Die and clean tracker */
  .die { width: 38px; height: 38px; font-size: 20px; }
  .clean-step { width: 28px; height: 22px; font-size: 10px; }

  /* Status */
  #status { padding: 5px 10px; min-height: 34px; font-size: 12px; }
  #status button { padding: 4px 10px; font-size: 11px; }

  /* Board container. Give a bit more height on phones in landscape */
  #board-container { height: 52vw; max-height: 42vh; }

  /* Info overlay */
  #info-card { width: 94%; padding: 16px 18px; }

  /* Game over */
  .final-scores { min-width: unset; width: calc(100vw - 48px); padding: 16px; }
}

/* ===== TUTORIAL ===== */
/* Desktop: inline flex item at the bottom of #game. No fixed positioning */
#tutorial-overlay {
  display: none;
  flex-shrink: 0;
  pointer-events: none;
  border-top: 3px solid #62b517;
  background: #fff;
  box-shadow: 0 -3px 16px rgba(0,0,0,0.10);
}
#tutorial-overlay.active { display: block; }
#tutorial-card {
  background: transparent;
  border-radius: 0;
  padding: 10px 20px 12px;
  max-width: none;
  box-shadow: none;
  border-top: none;
  pointer-events: all;
}

/* Mobile: restore the bottom-sheet style */
@media (max-width: 768px) {
  #tutorial-overlay {
    position: fixed; bottom: 0; left: 0; right: 0;
    z-index: 300;
    background: transparent;
    border-top: none;
    box-shadow: none;
  }
  #tutorial-card {
    background: #fff;
    border-radius: 14px 14px 0 0;
    padding: 14px 20px 16px;
    max-width: 640px;
    margin: 0 auto;
    box-shadow: 0 -4px 28px rgba(0,0,0,0.16);
    border-top: 3px solid #62b517;
  }
  /* Pad below status bar so it isn't hidden behind the fixed tutorial card */
  #game.tut-active { padding-bottom: 220px; }
}
.tut-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
#tut-step { font-size: 11px; font-weight: 700; color: #aaa; text-transform: uppercase; letter-spacing: 1px; white-space: nowrap; }
.tut-progress { flex: 1; height: 4px; background: #e8e4dc; border-radius: 4px; overflow: hidden; }
#tut-progress-fill { height: 100%; background: #62b517; border-radius: 4px; transition: width 0.35s ease; }
#tutorial-card h3 { font-size: 15px; color: #62b517; font-weight: 800; margin-bottom: 6px; }
#tutorial-card p { font-size: 13px; color: #555; line-height: 1.55; margin-bottom: 5px; }
#tutorial-card ul { font-size: 13px; color: #555; line-height: 1.6; padding-left: 18px; margin-bottom: 5px; }
#tutorial-card li { margin-bottom: 3px; }
#tutorial-card .tut-tip {
  background: #f4fae8; border-radius: 6px; padding: 6px 10px; margin: 6px 0;
  font-size: 12px; color: #62b517; border-left: 3px solid #62b517;
}
#tutorial-card .tut-action {
  background: #f0f6ff; border-radius: 6px; padding: 6px 10px; margin: 6px 0;
  font-size: 12px; color: #2060bb; border-left: 3px solid #4a9eff;
  font-weight: 600;
}
.tut-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; align-items: center; }
.tut-footer-left { font-size: 12px; color: #aaa; flex: 1; }
#tut-exit { padding: 7px 14px; border: 1px solid #ddd; border-radius: 8px; background: transparent; color: #888; font-size: 13px; cursor: pointer; font-family: inherit; }
#tut-exit:hover { background: #e8edd8; }
#tut-next { padding: 8px 20px; background: #62b517; color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit; }
#tut-next:hover { background: #235438; }

/* ===== FULLSCREEN MODE (intro / context / setup steps) ===== */
#tutorial-overlay.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 22, 4, 0.95);
  border-top: none;
  box-shadow: none;
  padding: 24px;
}
#tutorial-overlay.fullscreen #tutorial-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px 32px 24px;
  max-width: 740px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.55);
  border-top: 4px solid #62b517;
  pointer-events: all;
}
#tutorial-overlay.fullscreen #tutorial-card h3 { font-size: 18px; margin-bottom: 10px; }
#tutorial-overlay.fullscreen #tutorial-card p { font-size: 14px; line-height: 1.6; }
@media (max-width: 768px) {
  #tutorial-overlay.fullscreen {
    align-items: flex-end;
    padding: 0;
  }
  #tutorial-overlay.fullscreen #tutorial-card {
    border-radius: 16px 16px 0 0;
    max-height: 88vh;
    padding: 20px 18px 18px;
  }
}

/* Lobby tutorial button */
.btn-tutorial { background: #f4fae8; color: #4a8c11; border: 2px solid #a8c96a; max-width: 360px; }
.btn-tutorial:hover:not(:disabled) { background: #e8f5d0; border-color: #62b517; }

/* Tutorial node highlight (pulsing glow on the target node) */
.node-circle.tut-node-hl { animation: tut-hl-pulse 1.1s ease-in-out infinite; }
/* Tutorial animal input highlight (same pulse on SVG rect) */
rect.tut-animal-hl { animation: tut-hl-pulse 1.1s ease-in-out infinite; }
@keyframes tut-hl-pulse {
  0%,100% { stroke: #d1db24; stroke-width: 4; filter: drop-shadow(0 0 6px #d1db24); }
  50%      { stroke: #4aff4a; stroke-width: 5; filter: drop-shadow(0 0 14px #4aff4a); }
}
/* Tutorial action button highlight */
.action-btn.tut-btn-hl { border-color: #4aff4a !important; color: #1a5e2f !important; background: #d4f5d4 !important; animation: tut-btn-pulse 1.1s ease-in-out infinite; cursor: pointer !important; }
/* Tutorial status-bar button highlight */
.tut-status-hl { border-color: #4aff4a !important; color: #1a5e2f !important; background: #d4f5d4 !important; animation: tut-btn-pulse 1.1s ease-in-out infinite; cursor: pointer !important; }
/* Tutorial die highlight */
.die.tut-die-hl { box-shadow: 0 0 0 3px #4aff4a, 0 0 10px 3px #4aff4a; animation: tut-btn-pulse 1.1s ease-in-out infinite; }
@keyframes tut-btn-pulse {
  0%,100% { box-shadow: 0 0 0 2px #c8e84a; }
  50%      { box-shadow: 0 0 10px 4px #4aff4a; }
}

@media (max-width: 768px) {
  #tutorial-card { padding: 12px 14px 14px; }
  #tutorial-card h3 { font-size: 14px; }
  #tutorial-card p, #tutorial-card li { font-size: 12px; }
}
