/* ═══ The Contraption — warm workshop theme ═══ */

:root {
    --bg: #0f0c08;
    --panel: #1c1610;
    --panel2: #282016;
    --line: #46392a;
    --brass: #e8a33d;
    --steel: #7a91a8;
    --danger: #ff4040;
    --green: #46e05a;
    --cyan: #4dd2ff;
    --text: #f2ead9;
    --muted: #a89474;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100%;
}
body {
    background-image:
        radial-gradient(ellipse at 15% -10%, rgba(160, 110, 40, .18), transparent 55%),
        radial-gradient(ellipse at 95% 110%, rgba(122, 145, 168, .1), transparent 50%);
}

h1, h2, h3 { font-weight: 700; letter-spacing: .04em; }
h2 { font-size: 1.05rem; color: var(--brass); text-transform: uppercase; margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: 'Consolas', monospace; }
.hidden { display: none !important; }

.btn {
    display: inline-block; background: var(--panel2); color: var(--text);
    border: 1px solid var(--line); border-radius: 8px; padding: 10px 18px;
    font-size: .95rem; font-weight: 600; cursor: pointer; transition: all .15s;
    font-family: inherit;
}
.btn:hover { border-color: var(--brass); box-shadow: 0 0 14px rgba(232, 163, 61, .3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, #7a5a1a, #54400e); border-color: #a8842e; color: #ffedc4; }
.btn-large { width: 100%; padding: 14px; font-size: 1.1rem; margin-top: 14px; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; }

input, select {
    width: 100%; background: #120e08; border: 1px solid var(--line); border-radius: 8px;
    color: var(--text); padding: 11px 12px; font-size: 1rem; margin: 6px 0 14px;
    font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 12px rgba(232, 163, 61, .25); }
label { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.check-row { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: .9rem; margin-bottom: 6px; }
.check-row input { width: auto; margin: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }

/* ── Home / lobby (arcade shared layout) ── */
.home-container { max-width: 1000px; margin: 0 auto; padding: 28px 16px 60px; }
.hero { text-align: center; padding: 22px 0 30px; }
.game-title {
    font-size: clamp(2rem, 7vw, 3.4rem); letter-spacing: .1em; color: #fff4dd;
    text-shadow: 0 0 22px rgba(232, 163, 61, .5);
}
.tagline { margin-top: 12px; color: var(--muted); line-height: 1.6; }
.tagline-hot { color: #ffcf8a; }
.error-banner {
    background: rgba(255, 64, 64, .12); border: 1px solid #7a2020; color: #ffb0a0;
    border-radius: 10px; padding: 12px 16px; margin-bottom: 18px; text-align: center;
}
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .home-grid { grid-template-columns: 1fr; } }

.registry-head { margin: 20px 0 8px; font-size: .9rem; color: var(--muted); text-transform: uppercase; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.room-browser { list-style: none; max-height: 220px; overflow-y: auto; }
.room-row { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-bottom: 1px solid #241c12; cursor: pointer; }
.room-row:hover { background: rgba(232, 163, 61, .06); }
.room-code { font-family: monospace; font-size: 1.05rem; color: var(--cyan); letter-spacing: .12em; }
.room-row .btn { margin-left: auto; }
.empty-msg { padding: 14px 6px; }

.leaderboard-card { margin-top: 18px; }
.leaderboard { width: 100%; border-collapse: collapse; font-size: .9rem; }
.leaderboard th { color: var(--muted); text-align: left; font-size: .75rem; text-transform: uppercase; padding: 6px 8px; }
.leaderboard td { padding: 8px; border-top: 1px solid #241c12; }
.crew-names { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.how-to { margin-top: 34px; }
.how-to > h2 { text-align: center; margin-bottom: 18px; }
.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.how-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.how-icon { font-size: 1.6rem; display: block; margin-bottom: 8px; }
.how-card b { color: #fff; }
.how-card p { color: var(--muted); font-size: .87rem; margin-top: 6px; line-height: 1.5; }
.home-footer { text-align: center; margin-top: 30px; }

.lobby-container { max-width: 640px; margin: 0 auto; padding: 26px 16px 50px; text-align: center; }
.lobby-card { text-align: left; margin-bottom: 14px; }
.room-code-display { margin: 18px 0 6px; font-size: 1.1rem; }
.room-code-display .code { font-family: monospace; font-size: 1.6rem; color: var(--cyan); letter-spacing: .25em; margin: 0 8px; }
.share-hint { color: var(--muted); margin-bottom: 22px; font-size: .9rem; }
.player-list { list-style: none; }
.player-item { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid #241c12; }
.player-dot { width: 13px; height: 13px; border-radius: 50%; box-shadow: 0 0 8px currentColor; flex: none; }
.player-name { font-weight: 600; }
.host-badge {
    background: #3a2a00; color: var(--brass); font-size: .65rem;
    border: 1px solid #6a5210; padding: 2px 7px; border-radius: 20px; letter-spacing: .1em;
}
.waiting-msg { margin-top: 22px; color: var(--muted); }
.blink { animation: pulse 1.6s infinite; }
.start-hint { color: var(--muted); font-size: .85rem; margin-top: 10px; }

/* ═══ GAME SCREEN ═══ */
.game-shell {
    min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
    max-width: 640px; margin: 0 auto;
    padding: 0 10px calc(10px + env(safe-area-inset-bottom));
    position: relative; overflow: hidden;
}
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#flash.bad { animation: badFlash .55s; }
@keyframes badFlash { 0% { background: rgba(255, 40, 40, .35); } 100% { background: transparent; } }
#flash.good { animation: goodFlash .5s; }
@keyframes goodFlash { 0% { background: rgba(70, 224, 90, .22); } 100% { background: transparent; } }
.game-shell.shaking { animation: shake .45s; }
@keyframes shake {
    0%, 100% { transform: translate(0); } 25% { transform: translate(-9px, 3px); }
    50% { transform: translate(8px, -4px); } 75% { transform: translate(-5px, -2px); }
}

#hud-top {
    display: flex; align-items: center; gap: 8px;
    padding: calc(10px + env(safe-area-inset-top)) 2px 6px;
}
.mini-logo { font-weight: 800; letter-spacing: .05em; color: var(--brass); font-size: .85rem; white-space: nowrap; }
#order-chip {
    font-size: .68rem; font-weight: 800; letter-spacing: .1em; padding: 4px 10px;
    border-radius: 20px; border: 1px solid var(--line); color: var(--green);
    white-space: nowrap;
}
#quota-chip { font-family: monospace; font-size: 1rem; color: var(--brass); }
#lives { margin-left: auto; font-size: .95rem; letter-spacing: .04em; white-space: nowrap; }
.hud-icon-btn {
    background: var(--panel); border: 1px solid var(--line); color: var(--text);
    width: 34px; height: 34px; border-radius: 10px; font-size: .95rem; cursor: pointer;
}

#line-strip { display: flex; gap: 4px; padding: 4px 0 8px; overflow-x: auto; }
.station-pip {
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    font-size: .62rem; color: var(--muted); background: var(--panel);
    border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px;
    min-width: 58px; flex: none;
}
.station-pip.me { border-color: var(--brass); color: var(--brass); box-shadow: 0 0 10px rgba(232, 163, 61, .3); }
.station-pip .ic { font-size: 1rem; }
.station-pip .q { letter-spacing: .15em; color: var(--cyan); min-height: 12px; }
.station-pip .nm { max-width: 74px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#tool-banner {
    text-align: center; font-size: .85rem; color: var(--muted);
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
    padding: 7px 12px; margin-bottom: 8px; line-height: 1.4;
}
#tool-banner b { color: var(--brass); }

#event-banner {
    position: absolute; top: 32%; left: 50%; transform: translateX(-50%); z-index: 12;
    font-size: clamp(1rem, 4.5vw, 1.5rem); font-weight: 800; letter-spacing: .08em;
    color: #ffedc4; text-shadow: 0 0 16px rgba(232, 163, 61, .8); text-align: center;
    opacity: 0; pointer-events: none; transition: opacity .25s; white-space: nowrap;
}
#event-banner.show { opacity: 1; }
#event-banner.bad { color: #ffb0a0; text-shadow: 0 0 16px rgba(255, 64, 64, .8); }
#event-banner.good { color: #c8ffd0; text-shadow: 0 0 16px rgba(70, 224, 90, .8); }

/* the workbench */
#bench { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#belt-in, #belt-out {
    height: 30px; display: flex; align-items: center; font-size: .72rem;
    color: var(--muted); letter-spacing: .06em;
    background: repeating-linear-gradient(90deg, #1a140c 0 26px, #221a10 26px 52px);
    border: 1px solid #2c2216; border-radius: 8px; padding: 0 12px;
}
#belt-in { justify-content: flex-start; }
#belt-out { justify-content: flex-end; }
#belt-in::before { content: '⬇ IN  '; color: var(--cyan); margin-right: 8px; }
#belt-out::after { content: '  OUT ➡'; color: var(--green); margin-left: 8px; }

#workspace {
    flex: 1; display: flex; align-items: center; justify-content: center;
    position: relative; min-height: 300px; padding: 10px 0;
}
.center-note { color: var(--muted); text-align: center; }

/* widget card */
.widget-card {
    width: min(400px, 92%); background: var(--panel); border: 2px solid var(--line);
    border-radius: 18px; padding: 14px; touch-action: none; user-select: none;
    -webkit-user-select: none; position: relative; cursor: grab;
    box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.widget-card.entering { animation: slideInLeft .35s ease; }
@keyframes slideInLeft { from { transform: translateX(-120%) rotate(-6deg); opacity: 0; } }
.widget-card.hands-off { border-color: var(--danger); }
.spec-line {
    text-align: center; font-weight: 800; letter-spacing: .05em; font-size: 1.02rem;
    margin-bottom: 8px; color: #fff;
}
.spec-line .warn { color: var(--danger); }
.timer-bar { height: 7px; background: #14100a; border-radius: 4px; overflow: hidden; margin-bottom: 10px; }
.timer-fill { height: 100%; background: linear-gradient(90deg, #e03030, #e8a33d, #46e05a); transition: width .5s linear; }

.widget-face {
    height: 130px; display: flex; align-items: center; justify-content: center;
    position: relative; margin-bottom: 10px;
}
.widget-body {
    width: 110px; height: 86px; border-radius: 16px; position: relative;
    display: flex; align-items: center; justify-content: center;
    box-shadow: inset 0 -8px 14px rgba(0,0,0,.35), 0 4px 10px rgba(0,0,0,.4);
    transition: transform .18s;
}
.widget-body .bolt { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: rgba(0,0,0,.4); }
.widget-body .bolt.tl { top: 7px; left: 7px; } .widget-body .bolt.tr { top: 7px; right: 7px; }
.widget-body .bolt.bl { bottom: 7px; left: 7px; } .widget-body .bolt.br { bottom: 7px; right: 7px; }
.widget-arrow { font-size: 2rem; color: rgba(0,0,0,.55); font-weight: 900; }
.widget-crack {
    position: absolute; font-size: 2.2rem; top: 4px; right: 10px;
    filter: drop-shadow(0 0 4px #000);
}
.stamp-mark {
    position: absolute; font-size: 1.5rem; color: rgba(120, 20, 20, .85);
    font-weight: 900; transform: rotate(-14deg); pointer-events: none;
}
.paint-splat { position: absolute; inset: 0; border-radius: 16px; opacity: .55; }

/* tool controls */
.tool-zone { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.big-act-btn {
    min-width: 170px; padding: 15px 24px; border-radius: 14px; font-weight: 900;
    font-size: 1.05rem; letter-spacing: .06em; border: 2px solid var(--brass);
    background: linear-gradient(180deg, #7a5a1a, #54400e); color: #ffedc4;
    cursor: pointer; font-family: inherit; touch-action: manipulation;
}
.big-act-btn:active { transform: translateY(3px); }
.paint-row { display: flex; gap: 10px; }
.paint-btn {
    width: 52px; height: 52px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25);
    cursor: pointer;
}
.paint-btn:active { transform: scale(.92); }
.gauge { width: 84%; height: 20px; background: #14100a; border-radius: 10px; position: relative; overflow: hidden; border: 1px solid var(--line); }
.gauge .zone { position: absolute; top: 0; bottom: 0; left: 60.8%; width: 26.2%; background: rgba(70, 224, 90, .25); border-left: 2px solid var(--green); border-right: 2px solid var(--green); }
.gauge .red { position: absolute; top: 0; bottom: 0; left: 100%; width: 0; border-left: 3px solid var(--danger); }
.gauge .needle { position: absolute; top: 0; bottom: 0; width: 26%; background: linear-gradient(90deg, transparent, var(--brass)); transition: width .12s; }
.cut-track {
    width: 84%; height: 46px; background: #14100a; border: 1px dashed var(--muted);
    border-radius: 12px; position: relative; touch-action: none;
}
.cut-knife {
    position: absolute; top: 3px; left: 3px; width: 46px; height: 36px;
    background: var(--steel); border-radius: 9px; display: flex; align-items: center;
    justify-content: center; font-size: 1.2rem; cursor: grab; touch-action: none;
}
.swipe-hint { font-size: .78rem; color: var(--muted); text-align: center; letter-spacing: .04em; }
.swipe-hint b { color: var(--green); }
.swipe-hint .bin { color: var(--danger); }

#queue-strip {
    display: flex; gap: 6px; justify-content: center; padding: 8px 0 4px; min-height: 34px;
}
.queue-chip {
    font-size: .7rem; padding: 4px 10px; border-radius: 20px;
    background: var(--panel); border: 1px solid var(--line); color: var(--muted);
    display: flex; align-items: center; gap: 5px;
}
.queue-chip .dot { width: 9px; height: 9px; border-radius: 3px; }
.queue-chip.urgent { border-color: var(--danger); color: #ffb0a0; animation: pulse .6s infinite; }

/* result overlay */
.overlay {
    position: fixed; inset: 0; z-index: 40; display: flex; align-items: center;
    justify-content: center; background: rgba(6, 4, 2, .85); padding: 14px;
}
.overlay-card {
    background: var(--panel); border: 1px solid #5a4620; border-radius: 16px;
    width: min(480px, 100%); padding: 26px; text-align: center;
}
#result-title { font-size: 1.5rem; letter-spacing: .1em; }
#result-title.lose { color: var(--danger); text-shadow: 0 0 18px rgba(255, 64, 64, .5); }
.result-stats { display: flex; justify-content: center; gap: 24px; flex-wrap: wrap; margin: 16px 0 6px; color: var(--muted); font-size: .9rem; }
.result-stats b { color: var(--text); display: block; font-size: 1.5rem; }
.results-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; align-items: center; }
