.loto-page {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(96%, 1780px);
    max-width: none;
    color: var(--text-main);
}

.loto-games-main { padding: 24px 0 42px; }

.loto-heading {
    display: grid;
    gap: 8px;
    padding: 0 4px;
}

.loto-heading > p,
.loto-panel p {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.5;
}

.loto-back {
    color: var(--text-muted);
    font-size: 13px;
    text-decoration: none;
}

.loto-back:hover { color: var(--accent); }

.loto-panel {
    min-width: 0;
    padding: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.loto-panel h2,
.loto-panel h3 { margin: 0; }
.loto-panel h2 { font-size: 20px; }
.loto-panel h3 { font-size: 16px; }
.loto-panel h3 span { color: var(--text-muted); font-size: 13px; font-weight: 500; }

.loto-entry {
    display: grid;
    gap: 16px;
    max-width: 700px;
}

.loto-name-field,
.loto-setting {
    display: grid;
    gap: 7px;
    color: var(--text-muted);
    font-size: 13px;
}

.loto-page input,
.loto-page select {
    min-height: 42px;
    padding: 9px 12px;
    color: var(--text-main);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.loto-entry-actions,
.loto-header-actions,
.loto-result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.loto-primary { color: #111; background: var(--accent); border-color: var(--accent); font-weight: 650; }
.loto-primary:hover { color: #111; background: #ffd633; }

.loto-join-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

.loto-join-form label { grid-column: 1 / -1; color: var(--text-muted); font-size: 13px; }
.loto-join-form .loto-watch-choice { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.loto-join-form .loto-watch-choice input { min-height: 0; accent-color: var(--accent); }
.loto-join-form input { text-transform: uppercase; letter-spacing: .12em; }
.loto-room { display: grid; gap: 10px; }
.loto-room-header { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.loto-room-header { padding: 12px 16px; }
.loto-room-header h2 { margin: 2px 0; font-size: 18px; }
.loto-room-header > div:first-child { display: grid; grid-template-columns: auto auto; align-items: center; column-gap: 12px; }
.loto-room-header .loto-back { grid-column: 1 / -1; }
.loto-room-header > div:first-child > p { font-size: 12px; }
.loto-room-header h2 span { color: var(--accent); letter-spacing: .1em; }
.loto-header-actions { justify-content: flex-end; }
.loto-mobile-tabs { display: none; gap: 8px; }
.loto-mobile-tabs button { flex: 1; }
.loto-mobile-tabs button.active { color: var(--accent); border-color: var(--accent); }
.loto-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 14px; align-items: start; }
.loto-main-column,
.loto-side-column { display: grid; gap: 14px; min-width: 0; }
.loto-panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.loto-panel-heading > div { display: grid; gap: 4px; }
.loto-setting { grid-template-columns: auto minmax(100px, 180px); align-items: center; margin: 16px 0; }
.loto-player-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 5px; }
.loto-player-row { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 6px 8px; background: #1a1a1a; border-radius: var(--radius-sm); }
.loto-player-row.is-turn { box-shadow: inset 2px 0 var(--accent); }
.loto-player-row span:first-child { overflow: hidden; text-overflow: ellipsis; }
.loto-player-identity { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.loto-player-avatar { display: grid; flex: 0 0 26px; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: var(--accent); background: #333; font-size: 11px; font-weight: 700; }
.loto-player-meta { flex: 0 1 auto; overflow: hidden; color: var(--text-muted); font-size: 11px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.loto-host-label,
.loto-winner-label { color: var(--accent); font-size: 11px; }
.loto-draw-panel { display: grid; justify-items: center; gap: 12px; padding: 0; background: transparent; border: 0; box-shadow: none; text-align: center; }
.loto-draw-summary,
.loto-draw-controls { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; }
.loto-draw-summary strong { font-variant-numeric: tabular-nums; }
.loto-draw-controls { color: var(--text-muted); font-size: 13px; }
.loto-recent { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-height: 31px; }
.loto-recent span { display: grid; place-items: center; width: 30px; height: 30px; background: #333; border-radius: 6px; font-size: 13px; }
.loto-recent span:first-child { color: #111; background: var(--accent); font-weight: 700; }
.loto-notice { min-height: 18px; color: var(--accent); font-size: 13px; }
.loto-layout.is-playing { grid-template-columns: minmax(0, 1fr); }
.loto-layout.is-playing .loto-play-workspace { grid-template-columns: minmax(0, 1fr); align-items: start; }
.loto-layout.is-playing .loto-machine-frame-shell { height: clamp(620px, 82vh, 920px); }
.loto-layout.is-playing .loto-side-column { grid-template-columns: minmax(0, 2fr) minmax(280px, .8fr); }
.loto-layout.is-playing .loto-side-column > section:last-child { order: -1; }
.loto-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 370px), 1fr)); gap: 12px; }
.loto-play-window { padding: 12px; overflow: hidden; }
.loto-play-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
.loto-machine-pane { min-width: 0; }
.loto-draw-panel { justify-items: stretch; text-align: left; }
.loto-draw-summary { padding: 4px 4px 0; }
.loto-machine-frame-shell { width: 100%; height: clamp(350px, 52vh, 510px); }
.loto-machine-frame { display: block; width: 100%; height: 100%; border: 0; border-radius: var(--radius-md); background: #222; }
.loto-machine-hint { text-align: center; }
.loto-ticket-gallery { display: grid; gap: 10px; min-width: 0; padding: 12px; border-top: 1px solid var(--border-color); }
.loto-ticket-gallery-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; }
.loto-ticket-gallery-heading h3 { margin: 0; font-size: 16px; }
.loto-cards { display: grid; gap: 12px; max-height: min(64vh, 680px); overflow: auto; padding: 2px 4px 4px 0; }
.loto-player-tickets { display: grid; gap: 8px; min-width: 0; }
.loto-player-tickets-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0; color: var(--text-muted); font-size: 13px; font-weight: 600; }
.loto-player-tickets-heading h4 { min-width: 0; margin: 0; overflow: hidden; font-size: inherit; font-weight: inherit; text-overflow: ellipsis; white-space: nowrap; }
.loto-card-pager { display: flex; align-items: center; gap: 5px; font-size: 11px; font-variant-numeric: tabular-nums; }
.loto-card-page-button { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; color: var(--text-main); background: #292929; border: 1px solid var(--border-color); border-radius: 5px; cursor: pointer; }
.loto-card-page-button:disabled { opacity: .4; cursor: default; }
.loto-player-ticket-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 10px; }
.loto-ticket { min-width: 0; }
.loto-cell.is-marked { padding: 2px; overflow: hidden; background: #191919; border-color: #755c43; }
.loto-cell-barrel { position: relative; display: grid; place-items: center; width: 86%; height: 86%; min-width: 0; padding: 0; color: #a9201c; background: linear-gradient(155deg, #e6c48e 0%, #d2aa74 52%, #af8052 100%); border: 2px solid #a92b27; border-radius: 50%; box-shadow: inset 0 2px 2px #fff8, inset 0 -4px 0 #8c593b, 0 3px 0 #714832, 0 4px 4px #0008; font: 800 clamp(9px, 1.3vw, 14px) Inter, sans-serif; line-height: 1; cursor: default; translate: var(--placement-x, 0%) var(--placement-y, 0%); touch-action: manipulation; }
.loto-cell-barrel::after { position: absolute; inset: 3px; content: ""; border: 1px solid rgb(255 255 255 / 22%); border-radius: 50%; pointer-events: none; }
.loto-cell-barrel:not(:disabled) { cursor: pointer; }
.loto-cell-barrel:disabled { opacity: 1; }
.loto-cell-barrel.is-wobbling { animation: loto-barrel-wobble .24s cubic-bezier(.25,.8,.4,1) 2 alternate; transform-origin: 50% 85%; }
@keyframes loto-barrel-wobble { from { transform: rotate(calc(var(--wobble-angle) * -1)); } to { transform: rotate(var(--wobble-angle)); } }
.loto-ticket { display: grid; gap: 9px; padding: 12px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); }
.loto-ticket.is-won { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(255, 204, 0, .22); }
.loto-ticket-title { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; }
.loto-ticket-grid { display: grid; gap: 3px; }
.loto-ticket-row { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 3px; border-radius: 3px; }
.loto-cell { position: relative; display: grid; place-items: center; aspect-ratio: 1 / 1; min-width: 0; background: #191919; border: 1px solid #343434; border-radius: 3px; font-size: clamp(11px, 2.1vw, 15px); font-weight: 600; font-variant-numeric: tabular-nums; }
.loto-cell.is-empty { background: #202020; }
.loto-cell.is-drop-allowed { border-color: #8a742d; box-shadow: inset 0 0 0 1px rgb(255 204 0 / 14%); }
.loto-cell.is-drop-target { border-color: var(--accent); background: #3d3722; box-shadow: inset 0 0 0 2px rgb(255 204 0 / 40%); }
.loto-cell.is-drop-invalid { border-color: #a84c45; box-shadow: inset 0 0 0 1px rgb(211 81 72 / 30%); }
.loto-cell.is-drawn { color: #111; background: var(--accent); border-color: var(--accent); }
.loto-cell.is-drawn::after { position: absolute; top: 0; right: 2px; content: "✓"; color: #111; font-size: 9px; line-height: 1; }
.loto-ticket-row.is-complete .loto-cell:not(.is-empty) { outline: 2px solid rgba(255, 204, 0, .5); outline-offset: -2px; }
.loto-number-board { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; margin-top: 12px; }
.loto-number-board span { display: grid; place-items: center; min-height: 27px; color: #686868; background: #191919; border-radius: 4px; font-size: 11px; font-variant-numeric: tabular-nums; }
.loto-number-board span.is-drawn { color: #111; background: var(--accent); font-weight: 700; }
.loto-number-board span.is-current { outline: 2px solid #fff; outline-offset: 1px; }
.loto-spectators { margin-top: 12px; color: var(--text-muted); font-size: 12px; line-height: 1.6; }
.loto-results { display: grid; gap: 10px; border-color: rgba(255, 204, 0, .5); }
.loto-results h3 { color: var(--accent); }
.loto-toast { position: fixed; z-index: 100; right: 18px; bottom: 18px; max-width: min(360px, calc(100vw - 36px)); padding: 12px 16px; color: var(--text-main); background: #333; border: 1px solid var(--accent); border-radius: var(--radius-md); opacity: 0; pointer-events: none; transition: opacity .16s ease; }
.loto-toast.is-visible { opacity: 1; }
.loto-muted { color: var(--text-muted); }
.hidden { display: none !important; }

.loto-machine-hint { min-height: 20px; margin: 0; color: var(--text-muted); font-size: 13px; }
.loto-turn-actions, .loto-marking-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.loto-marking-controls { padding: 10px; border: 1px solid #403a2b; border-radius: var(--radius-sm); background: #1a1916; }
.loto-marking-controls > span { flex: 1 1 100%; color: var(--text-muted); font-size: 12px; }
.loto-turn-order { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: 100%; }
.loto-turn-chip { padding: 5px 8px; color: var(--text-muted); background: #262523; border: 1px solid #3c3a36; border-radius: 999px; font-size: 11px; }
.loto-turn-chip.is-active { color: #17130a; background: var(--accent); border-color: var(--accent); font-weight: 700; }
.loto-turn-chip.is-complete:not(.is-active) { opacity: .5; text-decoration: line-through; }
.loto-cell.is-marked { color: var(--text-main); background: #191919; border-color: #755c43; }
.loto-cell:disabled { opacity: 1; cursor: default; }
.loto-cell.is-empty { cursor: default; }
.loto-cell.is-drawn::after { content: "✓"; }
button.loto-cell:not(:disabled) { cursor: pointer; }
.loto-cell:not(span) { padding: 0; color: inherit; font-family: inherit; font-size: clamp(11px, 2.1vw, 15px); font-weight: 600; line-height: normal; }

@media (max-width: 820px) {
    .loto-layout { grid-template-columns: minmax(0, 1fr); }
    .loto-mobile-tabs { display: flex; }
    .loto-side-column { display: none; }
    .loto-side-column.is-mobile-active { display: grid; }
    .loto-main-column.is-mobile-hidden { display: none; }
    .loto-room-header { align-items: flex-start; }
    .loto-layout.is-playing .loto-play-workspace { grid-template-columns: minmax(0, 1fr); }
    .loto-layout.is-playing .loto-side-column { grid-template-columns: minmax(0, 1fr); }
    .loto-layout.is-playing .loto-side-column > section:last-child { order: 0; }
    .loto-layout.is-playing .loto-ticket-gallery { max-height: none; overflow: visible; padding: 10px 4px; border-top: 1px solid var(--border-color); border-left: 0; }
    .loto-layout.is-playing .loto-cards { max-height: 58vh; }
}

@media (max-width: 1100px) {
    .loto-layout.is-playing .loto-play-workspace { grid-template-columns: minmax(0, 1fr); }
    .loto-layout.is-playing .loto-ticket-gallery { max-height: none; overflow: visible; padding: 10px 4px; border-top: 1px solid var(--border-color); border-left: 0; }
    .loto-layout.is-playing .loto-cards { max-height: 58vh; }
}

@media (max-width: 520px) {
    .loto-room-header { flex-direction: column; }
    .loto-header-actions { width: 100%; justify-content: stretch; }
    .loto-header-actions > * { flex: 1; text-align: center; }
    .loto-panel { padding: 14px; }
    .loto-panel-heading { align-items: flex-start; flex-direction: column; }
    .loto-setting { grid-template-columns: 1fr; }
    .loto-draw-controls { align-items: flex-start; }
    .loto-cell { aspect-ratio: 1 / 1; font-size: 11px; }
    .loto-cell:not(span) { font-size: 11px; }
    .loto-play-window { padding: 7px; }
    .loto-machine-frame-shell { height: 390px; }
    .loto-ticket-gallery { padding: 10px 4px; }
    .loto-cards { max-height: 60vh; }
    .loto-player-ticket-grid { grid-template-columns: minmax(0, 1fr); }
}
