/* Base */
:root { --bg: #0f172a; --panel: #1e293b; --panel-hover: #334155; --border: #475569; --text: #e2e8f0; --muted: #94a3b8; --accent: #38bdf8; --primary: #0ea5e9; --primary-hover: #0284c7; --danger: #f87171; --ok: #22c55e; --warn: #f59e0b; }
/* touch-action manipulation everywhere: no double-tap zoom (rink/tray use none, which wins) */
* { box-sizing: border-box; touch-action: manipulation; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; touch-action: manipulation; }
.btn:hover { background: var(--panel-hover); }
.btn:active { background: var(--panel-hover); border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { min-height: 48px; border-color: var(--primary); background: var(--primary); color: #fff; font-size: 16px; font-weight: 600; }
.btn-primary:hover, .btn-primary:active { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { border-color: rgba(248, 113, 113, 0.5); color: var(--danger); }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-exit { display: none; }
.is-fullscreen .icon-enter { display: none; }
.is-fullscreen .icon-exit { display: block; }

/* Landing */
.landing { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
.landing-card { width: 100%; max-width: 400px; padding: 24px 20px; border-radius: 16px; background: var(--panel); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35); }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand-icon { border-radius: 10px; }
.brand-title { margin: 0; font-size: 22px; font-weight: 700; }
.brand-tagline { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* Landing tabs (join / create) */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 20px; border-radius: 10px; background: var(--bg); }
.tab { min-height: 40px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.tab[aria-selected="true"] { background: var(--panel-hover); color: var(--text); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Landing form (16px inputs so iOS Safari does not zoom on focus) */
.session-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.input { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-size: 16px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25); }
.form-error { min-height: 0; margin: 0; color: var(--danger); font-size: 14px; }
.form-error:empty { display: none; }
.form-hint { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }
.landing-version { margin: 16px 0 0; color: var(--muted); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }

/* Board layout: rink + control rail. data-layout (set by app.js) puts the rail on the right
   ("side": rink limited by height, e.g. phone portrait with a vertical rink) or at the bottom
   ("bottom": rink limited by width), whichever leaves the bigger rink. The rail never covers the ice. */
.app { display: flex; height: 100vh; height: 100dvh; }
.app[data-layout="side"] { flex-direction: row; }
.app[data-layout="bottom"] { flex-direction: column; }
.board { flex: 1; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; }
.app[data-layout="side"] .board { padding: calc(4px + env(safe-area-inset-top)) 4px calc(4px + env(safe-area-inset-bottom)) calc(4px + env(safe-area-inset-left)); }
.app[data-layout="bottom"] .board { padding: calc(4px + env(safe-area-inset-top)) calc(4px + env(safe-area-inset-right)) 4px calc(4px + env(safe-area-inset-left)); }

/* Rail */
.rail { flex: none; display: flex; background: var(--panel); overflow: auto; overscroll-behavior: contain; }
.app[data-layout="side"] .rail { flex-direction: column; width: calc(62px + env(safe-area-inset-right)); padding: calc(6px + env(safe-area-inset-top)) calc(7px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) 7px; }
.app[data-layout="bottom"] .rail { flex-direction: row; justify-content: center; padding: 6px calc(6px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) calc(6px + env(safe-area-inset-left)); }
.rail-main, .rail-tray, .tray-items { display: flex; align-items: center; gap: 6px; }
.app[data-layout="side"] .rail-main, .app[data-layout="side"] .rail-tray, .app[data-layout="side"] .tray-items { flex-direction: column; }
.app[data-layout="side"] .rail-main, .app[data-layout="side"] .rail-tray { margin: auto 0; }
.app[data-layout="bottom"] .rail-main, .app[data-layout="bottom"] .rail-tray, .app[data-layout="bottom"] .tray-items { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.rail-sep { flex: none; background: var(--border); }
.app[data-layout="side"] .rail-sep { width: 30px; height: 1px; margin: 2px 0; }
.app[data-layout="bottom"] .rail-sep { width: 1px; height: 30px; margin: 0 2px; }
.rbtn { position: relative; flex: none; flex-direction: column; gap: 2px; width: 48px; min-height: 44px; padding: 0; }
.rbtn[aria-expanded="true"] { border-color: var(--accent); background: var(--panel-hover); }
.rbtn-label { font-size: 10px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.rail-version { flex: none; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.swatches { display: inline-flex; }
.swatches i { width: 12px; height: 12px; border: 2px solid var(--panel); border-radius: 50%; }
.swatches i + i { margin-left: -5px; }

/* Connection status (badge on the people button) */
.status-dot { position: absolute; top: 4px; right: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 2px var(--panel); }
.status-dot[data-status="online"] { background: var(--ok); }
.status-dot[data-status="offline"] { background: var(--danger); }

/* Session / participants panel (positioned next to the people button by app.js) */
.people-panel { position: fixed; z-index: 20; width: 260px; max-width: calc(100vw - 16px); padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); }
.panel-session { margin: 0; overflow: hidden; font-size: 16px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.panel-version { margin: 2px 0 12px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.panel-build { opacity: 0.7; }
.panel-heading { margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.people-list { max-height: 40vh; margin: 0 0 12px; padding: 0; overflow-y: auto; list-style: none; }
.person { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 15px; }
.person-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.person-tag { flex: none; padding: 1px 6px; border-radius: 6px; background: var(--panel-hover); color: var(--muted); font-size: 11px; font-weight: 600; }
.people-panel .btn-danger { width: 100%; }

/* Tray items (inside the rail) */
.tray-items { touch-action: none; }
.tray-item { flex: none; width: 44px; height: 44px; padding: 0; border: 2px solid rgba(15, 23, 42, 0.6); border-radius: 50%; color: #fff; font: inherit; font-size: 14px; font-weight: 700; text-shadow: 0 0 2px rgba(15, 23, 42, 0.9), 0 0 1px rgba(15, 23, 42, 0.9); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.tray-item:active { cursor: grabbing; }
.tray-item.is-armed { outline: 3px solid var(--accent); outline-offset: 2px; }
.tray-puck { display: flex; align-items: center; justify-content: center; background: #f4f8fb; }
.puck-icon { display: block; pointer-events: none; }
.tray-line { width: 48px; height: 36px; border-radius: 8px; background: #f4f8fb; cursor: pointer; }
.line-icon { display: block; width: 40px; height: 20px; margin: 0 auto; fill: currentColor; stroke: currentColor; stroke-width: 2.5; }
.tray-colors { display: flex; flex: none; gap: 8px; }
.app[data-layout="side"] .tray-colors { flex-direction: column; padding-bottom: 4px; }
.tray-color { width: 32px; height: 32px; padding: 0; border: 3px solid var(--panel); border-radius: 50%; box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.tray-color[aria-checked="true"] { box-shadow: 0 0 0 3px var(--accent); }

/* Marker being dragged from the tray */
.drag-ghost.drag-ghost-puck { border: 0; background: transparent; box-shadow: none; }
.drag-ghost { position: fixed; z-index: 100; left: 0; top: 0; display: flex; align-items: center; justify-content: center; border: 2px solid rgba(15, 23, 42, 0.7); border-radius: 50%; color: #fff; font-weight: 700; text-shadow: 0 0 2px rgba(15, 23, 42, 0.9); pointer-events: none; opacity: 0.9; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); }

/* Rink SVG (units are feet; --thin is set by rink.js so 2" lines stay visible) */
.rink-svg { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
.rink-svg .boards { fill: none; stroke: #f8fafc; stroke-width: 1.2px; }
.rink-svg .ice { fill: #f4f8fb; }
.rink-svg .boards-edge { fill: none; stroke: #334155; stroke-width: var(--thin, 0.17px); }
.rink-svg .thin { stroke-width: var(--thin, 0.17px); }
.rink-svg .red-line { fill: none; stroke: #c8102e; }
.rink-svg .blue-line { fill: none; stroke: #0033a0; }
.rink-svg .red-fill { fill: #c8102e; }
.rink-svg .blue-fill { fill: #0033a0; }
.rink-svg .center-marks { fill: none; stroke: #f4f8fb; }
.rink-svg .crease { fill: #7fb2e5; stroke: #c8102e; }
.rink-svg .spot { fill: #f4f8fb; stroke: #c8102e; }
.rink-svg .net { fill: rgba(148, 163, 184, 0.35); stroke: #c8102e; }
.rink-svg .post { fill: #c8102e; }

/* Board elements (feet units) */
.rink-svg .el { cursor: grab; }
.rink-svg .el.is-dragging { cursor: grabbing; }
.rink-svg .el-body { stroke: #0f172a; stroke-width: 0.35px; }
.rink-svg .el-ring { display: none; fill: rgba(14, 165, 233, 0.18); stroke: #0284c7; stroke-width: 0.45px; }
.rink-svg .el.is-selected .el-ring { display: block; }
.rink-svg .el-label { fill: #fff; stroke: #0f172a; stroke-width: 0.45px; paint-order: stroke; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-weight: 700; pointer-events: none; }
.rink-svg.is-drawing { cursor: crosshair; }

/* Lines (feet units) */
.rink-svg .el-line, .rink-svg .line-preview { color: #111827; }
.rink-svg .line-stroke, .rink-svg .line-preview { fill: none; stroke: currentColor; stroke-width: 0.7px; stroke-linecap: round; stroke-linejoin: round; }
.rink-svg .is-dashed .line-stroke, .rink-svg .line-preview.is-dashed { stroke-dasharray: 2.2 1.6; stroke-linecap: butt; }
.rink-svg .line-preview { opacity: 0.6; }
.rink-svg .line-arrow { fill: currentColor; }
.rink-svg .line-halo { display: none; fill: none; stroke: rgba(14, 165, 233, 0.35); stroke-width: 2.4px; stroke-linecap: round; stroke-linejoin: round; }
.rink-svg .el-line.is-selected .line-halo { display: block; }
