:root {
    --accent: #3fbf5f;
    --accent-ink: #062512;
    --warn: #f2c14e;
    --bad: #ff8a80;
    --panel: rgba(12, 20, 15, 0.84);
    --panel-2: rgba(255, 255, 255, 0.05);
    --line: rgba(255, 255, 255, 0.1);
    --text: #eef4f0;
    --muted: #9fb3a6;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0e1410; color: var(--text); font-family: 'Inter', system-ui, sans-serif;
    -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#c { position: fixed; inset: 0; display: block; width: 100vw; height: 100vh; touch-action: none; }
.hidden { display: none !important; }
h1, h2, h3, p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
.screen { position: fixed; inset: 0; display: flex; align-items: flex-start; justify-content: center; padding: 16px; overflow: auto; z-index: 15; }
.screen > .panel { margin-block: auto; }
@media (max-height: 520px) { .screen { padding-top: 58px; } }
.screen.dim { background: radial-gradient(ellipse at center, rgba(6, 12, 8, 0.3), rgba(6, 12, 8, 0.7)); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 24px 70px rgba(0,0,0,0.45); }
.btn { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-weight: 700; font-size: 0.95rem; padding: 11px 18px; border-radius: 12px; transition: transform 0.12s, background-color 0.2s, border-color 0.2s; }
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; font-weight: 800; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.big { width: 100%; font-size: 1.02rem; padding: 14px 20px; }
.field { width: 100%; font: 600 1rem 'Inter', sans-serif; color: var(--text); background: rgba(0,0,0,0.35); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none; -webkit-user-select: text; user-select: text; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(63, 191, 95, 0.18); }
.kicker { color: var(--accent); font-weight: 800; font-size: 0.75rem; letter-spacing: 0.2em; text-transform: uppercase; }
.status { min-height: 1.3em; color: var(--muted); font-size: 0.88rem; }
.status.error { color: var(--bad); }
body.is-host .client-only { display: none !important; }
body:not(.is-host) .host-only { display: none !important; }
body:not(.in-game) .game-only { display: none !important; }

/* Menu */
.menu-panel { width: 100%; max-width: 420px; padding: 30px 26px; text-align: center; }
.logo { font-family: 'Bungee', sans-serif; font-size: clamp(2.4rem, 10vw, 3.4rem); line-height: 0.95; color: #fff; text-shadow: 0 4px 0 #14532d, 0 10px 30px rgba(0,0,0,0.4); }
.logo span { display: block; color: var(--warn); text-shadow: 0 4px 0 #6b4d0c, 0 10px 30px rgba(0,0,0,0.4); }
.tagline { color: var(--muted); margin: 14px auto 20px; max-width: 330px; line-height: 1.5; }
.menu-form { display: grid; gap: 10px; text-align: left; margin-bottom: 10px; }
.menu-form label { font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.join-row { display: flex; gap: 8px; }
.join-row .field { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 800; text-align: center; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.15em; margin: 6px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.invite { background: rgba(242,193,78,0.12); border: 1px solid rgba(242,193,78,0.4); color: #ffe2a0; border-radius: 12px; padding: 10px 12px; font-weight: 600; font-size: 0.9rem; margin-bottom: 14px; }

/* Lobby */
.lobby-panel { width: 100%; max-width: 440px; padding: 22px; }
.room-box { background: rgba(0,0,0,0.3); border: 1px dashed rgba(255,255,255,0.2); border-radius: 14px; padding: 12px; text-align: center; margin-bottom: 14px; }
.room-box small { color: var(--muted); font-weight: 800; font-size: 0.68rem; letter-spacing: 0.15em; text-transform: uppercase; }
.room-code { font-family: 'Bungee', sans-serif; font-size: 2rem; letter-spacing: 0.12em; color: var(--warn); margin: 2px 0 8px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; margin-bottom: 8px; }
.section-title small { color: var(--muted); font-weight: 700; }
.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; margin-bottom: 14px; }
.player { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--panel-2); border: 1px solid transparent; font-size: 0.9rem; }
.player.me { border-color: rgba(63, 191, 95, 0.5); }
.player .dot, .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.player .who { flex: 1; min-width: 0; }
.player .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 0.64rem; font-weight: 800; padding: 3px 7px; border-radius: 6px; background: rgba(255,255,255,0.08); color: var(--muted); text-transform: uppercase; }
.badge.ok { background: rgba(63, 191, 95, 0.18); color: var(--accent); }
.badge.host { background: rgba(242,193,78,0.16); color: var(--warn); }
.lobby-actions { display: grid; gap: 8px; }
.kick { margin-left: 6px; background: none; border: 1px solid var(--line); color: var(--muted); font-family: inherit; font-size: 0.72rem; font-weight: 700; padding: 4px 9px; border-radius: 8px; cursor: pointer; }
.kick:hover { border-color: #e0584f; color: var(--bad); }
.chip { background: rgba(0,0,0,0.45); border: 1px solid var(--line); border-radius: 10px; padding: 5px 10px; font-weight: 800; font-size: 0.85rem; color: var(--muted); }
.chip b { color: #fff; }

/* Top controls (same as every Yoahka game) */
.corner { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; z-index: 20; }
.corner .btn { padding: 7px 12px; font-size: 0.8rem; background: rgba(0,0,0,0.45); display: inline-flex; align-items: center; }
.corner #btn-view.on { border-color: var(--accent); color: var(--accent); }
.corner svg { width: 16px; height: 16px; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { position: absolute; }
.hud-tl { top: 14px; left: 16px; display: grid; gap: 8px; }
.hole-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px 12px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.hole-name { font-family: 'Bungee', sans-serif; font-size: 1.15rem; line-height: 1.15; margin: 2px 0 8px; }
.hole-meta { display: flex; gap: 6px; }
.score-col { display: grid; gap: 4px; }
.ph { display: flex; align-items: center; gap: 7px; font-size: 0.75rem; font-weight: 700; background: rgba(0,0,0,0.45); padding: 4px 9px; border-radius: 8px; min-width: 150px; }
.ph.me { outline: 1px solid rgba(63, 191, 95, 0.6); }
.ph.done { opacity: 0.65; }
.ph .dot { width: 10px; height: 10px; }
.ph .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
.ph .n { font-weight: 800; min-width: 22px; text-align: right; }
.ph .tot { color: var(--muted); font-size: 0.7rem; min-width: 18px; text-align: right; }
.pill { top: 58px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.55); border: 1px solid var(--line); padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 0.85rem; white-space: nowrap; }
#timer { color: var(--warn); }
#waiting { top: auto; bottom: 96px; }
#power { bottom: max(26px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 5px;
    background: rgba(0,0,0,0.5); border: 1px solid var(--line); border-radius: 999px; padding: 10px 18px 7px; }
#power small { color: var(--muted); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.2em; }
#power-track { width: min(260px, 58vw); height: 10px; border-radius: 99px; background: rgba(255,255,255,0.1); overflow: hidden; }
#power-fill { height: 100%; width: 0; border-radius: 99px; }
#hint { bottom: max(22px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.45); border: 1px solid var(--line);
    padding: 7px 14px; border-radius: 999px; font-size: 0.82rem; font-weight: 700; color: var(--muted); white-space: nowrap; transition: opacity 0.6s; }
#hint.faded { opacity: 0; }
#power:not(.hidden) ~ #hint { opacity: 0; }

/* Name tags over other balls */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.label { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 5px; background: rgba(0,0,0,0.55); border: 1px solid var(--line); color: var(--text);
    padding: 2px 8px; border-radius: 8px; font: 700 0.72rem 'Inter', sans-serif; white-space: nowrap; transition: opacity 0.2s; will-change: transform; }
.label .dot { width: 8px; height: 8px; }

/* Big centre message */
.banner { position: fixed; top: 28%; left: 0; right: 0; z-index: 30; pointer-events: none; text-align: center; opacity: 0; transform: scale(0.6);
    transition: opacity 0.25s, transform 0.4s cubic-bezier(0.2, 1.6, 0.4, 1); }
.banner.show { opacity: 1; transform: scale(1); }
.b-main { font-family: 'Bungee', sans-serif; font-size: clamp(2.4rem, 10vw, 5.5rem); line-height: 1; color: #fff; text-shadow: 0 6px 0 rgba(0,0,0,0.3), 0 10px 40px rgba(0,0,0,0.4); }
.b-sub { font-weight: 800; font-size: 1rem; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,0.6); margin-top: 6px; }
.banner.good .b-main { color: var(--accent); }
.banner.ace .b-main { color: var(--warn); }
.banner.intro .b-main { font-size: clamp(2rem, 8vw, 4rem); }

/* Scorecard & results */
.results-panel { width: 100%; max-width: 500px; padding: 26px; text-align: center; }
.results-panel.wide { max-width: 760px; }
.results-panel h2 { font-family: 'Bungee', sans-serif; font-size: clamp(1.6rem, 5vw, 2.2rem); margin: 6px 0 16px; }
.results-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; align-items: center; margin-top: 14px; }
#board-next { margin-top: 10px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,0.2); }
table { border-collapse: collapse; width: 100%; font-size: 0.85rem; font-weight: 700; min-width: 520px; }
th, td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: none; }
th { color: var(--muted); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.05em; }
th.cur { color: var(--accent); }
td.cur { background: rgba(63, 191, 95, 0.08); }
tr.par td { color: var(--muted); font-size: 0.75rem; }
td.pl, th.pl { text-align: left; padding-left: 12px; white-space: nowrap; }
td.pl .dot { width: 10px; height: 10px; margin-right: 8px; vertical-align: -1px; }
tr.me td { background: rgba(63, 191, 95, 0.12); }
td.under { color: var(--accent); } td.over { color: var(--bad); } td.even { color: var(--muted); }
td.ace { color: var(--accent-ink); background: var(--warn) !important; border-radius: 6px; }
td.tot { font-weight: 900; color: #fff; }

#podium { display: flex; justify-content: center; align-items: flex-end; gap: 8px; margin-bottom: 14px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; min-width: 96px; font-size: 0.82rem; color: var(--muted); }
.pod b { color: var(--text); font-size: 0.95rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .place { font-family: 'Bungee', sans-serif; font-size: 1.5rem; line-height: 1; }
.pod.p1 { padding-top: 20px; border-color: rgba(255, 209, 102, 0.5); background: rgba(242, 193, 78, 0.1); }
.pod.p1 .place { color: #ffd166; } .pod.p2 .place { color: #dfe6ee; } .pod.p3 .place { color: #e0a068; }

/* Toasts */
#toasts { position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); display: grid; gap: 6px; z-index: 30; pointer-events: none; justify-items: center; }
.toast { background: rgba(0,0,0,0.72); border: 1px solid var(--line); padding: 8px 14px; border-radius: 10px; font-weight: 700; font-size: 0.88rem; animation: toast 3.2s forwards; white-space: nowrap; }
@keyframes toast { 0% { opacity: 0; transform: translateY(8px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* Phones: keep the top controls clear of the hole card */
@media (max-width: 600px) {
    .hud-tl { top: 58px; left: 10px; }
    .hole-box { padding: 8px 12px 10px; }
    .hole-name { font-size: 0.95rem; margin-bottom: 6px; }
    .chip { font-size: 0.75rem; padding: 4px 8px; }
    .ph { min-width: 0; font-size: 0.7rem; }
    .ph .nm { max-width: 80px; }
    .pill { top: auto; bottom: 70px; }
    #waiting { bottom: 110px; }
    #hint { font-size: 0.75rem; }
}
@media (max-height: 520px) { .score-col { display: none; } }
