/* ===== Caro pages (lobby, game, leaderboard). Builds on the shared skin tokens (--op-*, --lm-*). ===== */
:root {
    --caro-x: #E86F2C;            /* same orange as the app accent */
    --caro-o: #2563EB;
    --caro-board: #F7E7C6;        /* warm wood */
    --caro-board-2: #F2DCB0;
    --caro-line: rgba(120, 78, 30, .28);
    --caro-frame: #C99A5B;
    --caro-last: rgba(255, 255, 255, .55);
    --caro-win: #FCD34D;
    --caro-preview: rgba(232, 111, 44, .22);
    --caro-ease: cubic-bezier(.2, .8, .2, 1);
}

.caro-body { margin: 0; background: var(--op-bg-page); color: var(--op-text); }
/* JS toggles panels with the hidden attribute; class rules that set display must not override it. */
.caro-body [hidden] { display: none !important; }
.caro-main { max-width: 820px; margin: 0 auto; padding: 16px 12px 48px; }
.caro-section { margin-bottom: 14px; }
.caro-nav { overflow-x: auto; min-width: 0; }
.caro-nav a { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }

/* Icons (SVG sprite in _icons.blade.php) */
.caro-ico { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round; }
.caro-ico--sm { width: 18px; height: 18px; }
.caro-btn-ico { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }

/* Buttons: never look tappable while disabled (boot or in-flight request). */
.caro-body button:disabled, .caro-body .lm-btn:disabled { opacity: .5; cursor: not-allowed; }
.caro-body .lm-btn { box-sizing: border-box; min-height: 44px; transition: transform .15s var(--caro-ease), box-shadow .15s, background-color .15s; }
.caro-body .lm-btn:not(:disabled):active { transform: scale(.97); }
.caro-body :focus-visible { outline: 3px solid rgba(232, 111, 44, .55); outline-offset: 2px; }

/* Hero */
.caro-hero { display: flex; align-items: center; gap: 14px; padding: 6px 2px 16px; }
.caro-hero h1 { font-size: clamp(22px, 5vw, 30px); font-weight: 800; margin: 0 0 2px; letter-spacing: -.02em; }
.caro-hero p { margin: 0; color: var(--op-text-2); font-size: 14px; line-height: 1.5; }
.caro-hero-badge { flex: none; width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
    color: #fff; background: linear-gradient(135deg, #F28B4B, var(--op-accent)); box-shadow: var(--lm-shadow-md); }
.caro-hero-badge .caro-ico { width: 28px; height: 28px; }
.caro-hero-badge--gold { background: linear-gradient(135deg, #FBBF24, #D97706); }

/* Lobby: guest prompt + two mode cards */
.caro-who .lm-field { margin: 0; }
.caro-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.caro-mode { display: flex; flex-direction: column; gap: 16px; justify-content: space-between; }
.caro-mode-head { display: flex; align-items: flex-start; gap: 12px; }
.caro-mode-head h2 { margin: 0 0 2px; font-size: 17px; font-weight: 700; }
.caro-mode-head p { margin: 0; font-size: 13.5px; color: var(--op-text-2); }
.caro-mode-icon { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
    color: var(--op-accent); background: var(--op-accent-light); }
.caro-mode-icon--ai { color: var(--caro-o); background: #E8EFFE; }
.caro-levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.caro-level { min-height: 56px; padding: 8px 6px; border-radius: var(--lm-r-md); border: 1.5px solid var(--op-border);
    background: #fff; color: var(--op-text); font: inherit; cursor: pointer; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 2px;
    transition: border-color .15s, background-color .15s, transform .15s var(--caro-ease); }
.caro-level b { font-size: 15px; }
.caro-level small { font-size: 11.5px; color: var(--op-text-2); }
.caro-level:not(:disabled):hover { border-color: var(--caro-o); background: #F3F6FF; }
.caro-level:not(:disabled):active { transform: scale(.97); }

/* Card headers + lists (rooms, my games) */
.caro-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.caro-card-head .caro-card-title { margin: 0; }

.caro-card-title { margin: 0 0 6px; font-size: 15px; font-weight: 700; }
.caro-leaderboard-note { margin: 0 0 8px; color: var(--op-text-2); font-size: 13px; }
.caro-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--op-text-2); }
.caro-live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--op-success);
    box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); animation: caro-live 2s infinite; }
.caro-list { list-style: none; margin: 0; padding: 0; }
.caro-list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--op-border-card); }
.caro-list li:last-child { border-bottom: 0; }
.caro-list .caro-row-main { min-width: 0; flex: 1; }
.caro-list .caro-row-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caro-list .caro-row-sub { font-size: 12.5px; color: var(--op-text-2); }
.caro-row-btn { flex: none; }
.caro-avatar { flex: none; width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center;
    font-weight: 700; color: var(--op-brown); background: var(--op-accent-light); }
.caro-avatar--ai { color: var(--caro-o); background: #E8EFFE; }
.caro-avatar--sm { width: 28px; height: 28px; font-size: 13px; margin-right: 8px; vertical-align: middle; }
.caro-empty { margin: 4px 0 0; color: var(--op-text-muted); font-size: 13.5px; }
.caro-empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 8px 8px;
    text-align: center; color: var(--op-text-muted); }
.caro-empty-state .caro-ico { width: 32px; height: 32px; opacity: .6; }
.caro-empty-state p { margin: 0; font-size: 13.5px; }

/* Game: players + turn header */
.caro-players { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-bottom: 8px; }
.caro-player { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; border-radius: var(--lm-r-md);
    background: #fff; border: 2px solid transparent; box-shadow: var(--lm-shadow-sm);
    transition: border-color .2s, box-shadow .2s, background-color .2s; }
.caro-player--right { justify-content: flex-end; text-align: right; }
.caro-player.is-turn { border-color: var(--op-accent); background: var(--op-accent-light); box-shadow: var(--lm-shadow-md); }
.caro-player[data-side="O"].is-turn { border-color: var(--caro-o); background: #EEF3FF; }
.caro-player > div { min-width: 0; }
.caro-player-name { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caro-player-meta { font-size: 12px; color: var(--op-text-2); }
.caro-stone { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
    background: var(--caro-board); box-shadow: inset 0 0 0 1px var(--caro-line); }
.caro-stone .caro-mark { width: 26px; height: 26px; }
.caro-turn { text-align: center; min-width: 96px; }
.caro-turn-text { font-weight: 700; font-size: 13.5px; }
.caro-timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 22px; color: var(--op-brown); }
.caro-timer.is-low { color: var(--op-error); }
.caro-timebar { height: 4px; margin: 0 auto 12px; border-radius: 99px; background: var(--op-border); overflow: hidden;
    opacity: 0; transition: opacity .2s; }
.caro-timebar.is-on { opacity: 1; }
.caro-timebar span { display: block; height: 100%; background: var(--op-accent); transform-origin: left center;
    transition: transform .25s linear, background-color .2s; }
.caro-timebar.is-low span { background: var(--op-error); }
.caro-notice { margin: 0 0 10px; padding: 10px 12px; border-radius: var(--lm-r-md); background: var(--op-bg-cat);
    color: var(--op-text-2); font-size: 13.5px; text-align: center; }
.caro-join-text { margin: 0 0 10px; font-weight: 600; }
.caro-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.caro-actions--end { justify-content: flex-end; }
.caro-invite-input { flex: 1 1 220px; min-width: 0; }

/* Board: fluid square that fits the phone width and, on desktop, the viewport height. */
.caro-board-wrap { display: flex; justify-content: center; margin-bottom: 10px; }
.caro-board { --size: min(calc(100vw - 24px), 620px, max(320px, calc(100vh - 250px)));
    width: var(--size); display: grid; padding: 0; /* columns set by caro-board.js from board_size */
    background: linear-gradient(135deg, var(--caro-board), var(--caro-board-2));
    border: 3px solid var(--caro-frame); border-radius: 12px; overflow: hidden; box-shadow: var(--lm-shadow-lg);
    touch-action: manipulation; user-select: none; -webkit-tap-highlight-color: transparent; }
@supports (height: 100dvh) {
    .caro-board { --size: min(calc(100vw - 24px), 620px, max(320px, calc(100dvh - 250px))); }
}
.caro-cell { position: relative; aspect-ratio: 1 / 1; padding: 0; margin: 0; border: 0;
    border-right: 1px solid var(--caro-line); border-bottom: 1px solid var(--caro-line);
    background: transparent; font-size: 0; color: transparent; cursor: default; transition: background-color .15s; }
.caro-cell.is-last-col { border-right: 0; }
.caro-cell.is-last-row { border-bottom: 0; }
.caro-cell:focus-visible { outline: 3px solid var(--op-accent); outline-offset: -3px; }
.caro-board.is-my-turn .caro-cell:empty { cursor: pointer; }
@media (hover: hover) {
    .caro-board.is-my-turn .caro-cell:empty:hover { background: var(--caro-preview); }
}
.caro-cell.is-star:empty::before { content: ''; position: absolute; left: 50%; top: 50%; width: 18%; height: 18%;
    border-radius: 50%; background: var(--caro-line); transform: translate(-50%, -50%); }
.caro-cell.is-last { background: var(--caro-last); box-shadow: inset 0 0 0 2px rgba(92, 59, 26, .35); }
.caro-cell.is-win { background: var(--caro-win); animation: caro-win 1.2s var(--caro-ease) 2; }
.caro-cell.is-preview { background: var(--caro-preview); box-shadow: inset 0 0 0 2px var(--op-accent); }
.caro-cell.is-pending::before, .caro-cell.is-pending::after { opacity: .5; }

/* Stones drawn with CSS so they stay crisp at any board size (cell text is kept only for state). */
.caro-mark { position: relative; display: block; }
.caro-cell.is-x::before, .caro-cell.is-x::after, .caro-mark.is-x::before, .caro-mark.is-x::after {
    content: ''; position: absolute; left: 21%; right: 21%; top: 50%; height: 13%; margin-top: -6.5%;
    border-radius: 99px; background: var(--caro-x); transform: rotate(45deg); }
.caro-cell.is-x::after, .caro-mark.is-x::after { transform: rotate(-45deg); }
.caro-cell.is-o::before, .caro-mark.is-o::before {
    content: ''; position: absolute; inset: 20%; border-radius: 50%;
    background: radial-gradient(circle, transparent 52%, var(--caro-o) 54%); }
.caro-cell.is-last::before, .caro-cell.is-last::after { animation: caro-pop .2s var(--caro-ease); }

.caro-hint { margin: -2px 0 10px; text-align: center; font-size: 13px; color: var(--op-text-2); }
.caro-toolbar { display: flex; justify-content: center; }

/* Result */
.caro-result { text-align: center; }
.caro-result-icon { width: 56px; height: 56px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center;
    color: #B45309; background: #FEF3C7; }
.caro-result-icon .caro-ico { width: 30px; height: 30px; }
.caro-result[data-mood="lose"] .caro-result-icon { color: var(--op-text-2); background: var(--op-bg-cat); }
.caro-result[data-mood="draw"] .caro-result-icon, .caro-result[data-mood="neutral"] .caro-result-icon {
    color: var(--caro-o); background: #E8EFFE; }
.caro-result-title { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.caro-result-detail { color: var(--op-text-2); margin-bottom: 14px; }
.caro-result .caro-actions { justify-content: center; }
.caro-result:not([hidden]) { animation: caro-rise .25s var(--caro-ease); }

/* In-page modal */
.caro-modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px;
    background: rgba(26, 26, 26, .5); }
.caro-modal[hidden] { display: none; }
.caro-modal-box { width: min(100%, 360px); animation: caro-rise .2s var(--caro-ease); }
.caro-modal-box h2 { font-size: 18px; margin: 0 0 6px; }
.caro-modal-box p { color: var(--op-text-2); margin: 0 0 14px; }

/* Leaderboard */
.caro-tabs { display: flex; flex-wrap: wrap; margin: 0 0 14px; }
.caro-tabs .lm-pill { box-sizing: border-box; text-decoration: none; min-height: 40px; display: inline-flex; align-items: center; }
.caro-period { margin: 0 0 10px; font-size: 13px; color: var(--op-text-2); }
.caro-rank-table th.num, .caro-rank-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.caro-rank { width: 44px; }
.caro-medal { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
    font-weight: 700; font-size: 13px; color: var(--op-text-2); }
.caro-medal--1 { color: #7C4A03; background: linear-gradient(135deg, #FDE68A, #F59E0B); }
.caro-medal--2 { color: #374151; background: linear-gradient(135deg, #F3F4F6, #CBD5E1); }
.caro-medal--3 { color: #6B3410; background: linear-gradient(135deg, #FCD9B8, #D9925B); }
.caro-rank-name { max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.caro-rank-table tr.is-me td { background: var(--op-accent-light); }

@keyframes caro-pop { from { scale: .35; opacity: 0; } to { scale: 1; opacity: 1; } }
@keyframes caro-win { 50% { background: #FBBF24; } }
@keyframes caro-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes caro-live { 70% { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); } }

@media (prefers-reduced-motion: reduce) {
    .caro-body *, .caro-body *::before, .caro-body *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 640px) {
    .caro-modes { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .caro-main { padding: 12px 8px 40px; }
    .caro-hero-badge { width: 44px; height: 44px; border-radius: 14px; }
    .caro-players { grid-template-columns: 1fr 1fr; gap: 8px; }
    .caro-turn { grid-column: 1 / -1; order: -1; display: flex; align-items: baseline; justify-content: center; gap: 8px; }
    .caro-player { padding: 8px; gap: 8px; }
    .caro-board { --size: calc(100vw - 16px); border-width: 2px; border-radius: 8px; }
    .caro-actions > .lm-btn { flex: 1 1 auto; }
    .caro-rank-table th, .caro-rank-table td { padding: 9px 6px; font-size: 12.5px; }
    .caro-avatar--sm { display: none; }
    .caro-tabs { flex-wrap: nowrap; overflow-x: auto; }
    .caro-tabs .lm-pill { padding: 7px 11px; white-space: nowrap; }
    .lm-appbar { gap: 10px; }
    .caro-body .lm-brand { font-size: 0; gap: 0; }             /* keep only the logo badge */
    .caro-body .lm-brand .logo { font-size: 17px; }
    .caro-nav { scrollbar-width: none; }
    .caro-nav::-webkit-scrollbar { display: none; }
    .caro-nav .caro-ico { display: none; }
}

/* ===== Player account chip (app bar) ===== */
.play-account { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; min-width: 0; }
.play-account-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px;
    font-weight: 600; color: var(--op-text); text-decoration: none; padding: 10px 6px; }
.play-account-logout { margin: 0; }
.play-account-logout button, .play-account-login { box-sizing: border-box; min-height: 40px; padding: 8px 12px; border-radius: 10px; font: inherit;
    font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.play-account-logout button { border: 1px solid var(--op-border); background: #fff; color: var(--op-text-2); }
.play-account-login { margin-left: auto; color: #fff; background: var(--op-accent); border: 0; }

/* ===== "NV" badge: the player is a current employee ===== */
.caro-nv { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 6px; font-size: 10.5px; font-weight: 800;
    letter-spacing: .04em; vertical-align: 1px; color: var(--op-brown); background: var(--op-accent-light); }

/* ===== Room page ===== */
.caro-room-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 12px; }
.caro-room-head h1 { margin: 0; font-size: 20px; }
.caro-room-status { font-size: 13px; font-weight: 600; color: var(--op-text-2); }
.caro-seats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.caro-seat { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; flex-wrap: wrap; }
.caro-seat.is-me { border-color: var(--op-accent); }
.caro-seat.is-empty .caro-seat-name { color: var(--op-text-muted); font-weight: 600; }
.caro-seat-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--op-border); }
.caro-seat.is-online .caro-seat-dot { background: var(--op-success); }
.caro-seat-main { min-width: 0; flex: 1; }
.caro-seat-name { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caro-seat-meta { font-size: 12px; color: var(--op-text-2); }
.caro-seat.is-ready .caro-seat-meta { color: var(--op-success); font-weight: 600; }
/* 44 px touch targets (border-box: links default to content-box, where padding would add to the height). */
.caro-seat-join, .caro-ready-btn, #caro-login, #caro-leave, .caro-row-btn { min-height: 44px; box-sizing: border-box; }
.caro-room-toolbar { margin-top: 12px; }
@media (max-width: 480px) {
    .caro-seats { gap: 8px; }
    .caro-seat { padding: 8px 10px; gap: 8px; }
    /* Narrow screens: the account chip gets its own row so the nav links keep their labels. */
    .caro-body .lm-appbar { flex-wrap: wrap; gap: 8px 10px; }
    .caro-body .play-account, .caro-body .play-account-login { order: 3; width: 100%; justify-content: flex-end; margin-left: 0; }
    .play-account-name { max-width: 60vw; }
}
