:root { --bg:#eef7ff; --ink:#123; --card:#fff; --blue:#2563eb; --line:#d9e7f5; }
* { box-sizing: border-box; }
body { margin:0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color:var(--ink); background: radial-gradient(circle at top left,#c9f7ff,transparent 35%), linear-gradient(135deg,#fff7c2,#e8f4ff 45%,#fce7f3); min-height:100vh; }
button, .button-link { border:0; background:#e6eef8; padding:10px 14px; border-radius:14px; font-weight:700; cursor:pointer; text-decoration:none; color:#123; display:inline-block; }
button:hover, .button-link:hover { filter: brightness(.97); transform: translateY(-1px); }
button:disabled { opacity:.45; cursor:not-allowed; transform:none; }
.primary { background: linear-gradient(135deg,#2563eb,#06b6d4); color:white; }
.home { display:grid; place-items:center; padding:24px; }
.home-card { width:min(760px,100%); background:rgba(255,255,255,.88); border:1px solid rgba(255,255,255,.9); border-radius:28px; padding:28px; box-shadow:0 20px 60px #3b82f633; }
.logo { font-size: clamp(28px,5vw,46px); font-weight:900; color:#0f3a7a; text-shadow:2px 2px 0 #fff; }
.lead { font-size:18px; color:#475569; }
.panel { background:#fff; border:1px solid var(--line); border-radius:22px; padding:18px; margin-top:16px; }
.form { display:grid; grid-template-columns:1fr auto; gap:10px; }
.form input { min-width:0; padding:12px 14px; border:2px solid var(--line); border-radius:14px; font-size:16px; }
.error { background:#fee2e2; color:#991b1b; padding:12px; border-radius:14px; font-weight:700; }
.topbar { position:sticky; top:0; z-index:5; display:flex; justify-content:space-between; align-items:center; padding:12px 18px; background:rgba(255,255,255,.82); backdrop-filter: blur(12px); border-bottom:1px solid var(--line); }
.small { font-size:12px; color:#64748b; }
.room-code { font-size:28px; font-weight:900; letter-spacing:.18em; color:#1d4ed8; }
.top-actions { display:flex; gap:8px; align-items:center; }
.layout { width:min(1280px,100%); margin:0 auto; padding:18px; display:grid; grid-template-columns:1fr 360px; gap:18px; }
.card { background:rgba(255,255,255,.92); border:1px solid rgba(255,255,255,.9); border-radius:24px; padding:18px; box-shadow:0 12px 32px #2563eb1c; }
h1,h2 { margin:0 0 10px; }
h2 { margin-top:20px; font-size:20px; }
.status-line { display:flex; justify-content:space-between; gap:16px; align-items:flex-start; border-bottom:1px solid var(--line); padding-bottom:14px; }
.deck-info { display:flex; gap:10px; flex-wrap:wrap; }
.deck-info span { background:#f8fafc; border:1px solid var(--line); padding:8px 12px; border-radius:999px; }
.host-controls,.play-controls { display:flex; gap:10px; flex-wrap:wrap; margin:16px 0; }
.hint { color:#64748b; margin-top:-4px; }
.hand { display:flex; flex-wrap:wrap; gap:10px; min-height:100px; padding:12px; background:#f8fbff; border:1px dashed #b6d4ef; border-radius:18px; }
.atom-card { --c:#ddd; width:76px; min-height:106px; border-radius:16px; background:linear-gradient(180deg,var(--c),#fff 54%); border:3px solid #fff; box-shadow:0 6px 16px #0f172a22; display:flex; flex-direction:column; justify-content:center; align-items:center; gap:4px; }
.atom-card b { font-size:26px; }
.atom-card span { font-size:12px; }
.small-card { width:44px; min-height:58px; border-radius:10px; }
.bond-buttons,.formula-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:10px; }
.bond-btn,.formula { background:#fff; border:1px solid var(--line); border-radius:16px; padding:12px; display:grid; gap:4px; text-align:left; }
.bond-btn b,.formula strong { font-size:22px; color:#1d4ed8; }
.bond-btn em,.formula b { color:#db2777; font-style:normal; }
.formula.can { outline:3px solid #86efac; background:#f0fdf4; }
.formula small { color:#64748b; }
.side { display:grid; gap:18px; align-content:start; }
.players { display:grid; gap:10px; }
.player { border:1px solid var(--line); border-radius:16px; padding:12px; background:#fff; }
.player.active { outline:3px solid #93c5fd; }
.player-head { display:flex; justify-content:space-between; gap:10px; }
.player-head span { font-size:12px; color:#64748b; }
.score { font-size:20px; font-weight:900; color:#0f766e; margin:6px 0; }
.bonds { display:flex; flex-wrap:wrap; gap:6px; }
.bonds span { background:#eff6ff; color:#1d4ed8; border-radius:999px; padding:4px 8px; font-size:12px; font-weight:800; }
.log { max-height:420px; overflow:auto; display:grid; gap:8px; font-size:14px; }
.log div { background:#f8fafc; border-radius:12px; padding:8px; }
.empty { color:#64748b; padding:14px; }
.toast { position:fixed; left:50%; bottom:22px; transform:translateX(-50%); background:#0f172a; color:white; padding:12px 16px; border-radius:999px; box-shadow:0 8px 30px #0004; z-index:10; }
@media (max-width: 880px) { .layout { grid-template-columns:1fr; padding:10px; } .form { grid-template-columns:1fr; } .topbar { align-items:flex-start; gap:8px; } .top-actions { flex-wrap:wrap; justify-content:flex-end; } .atom-card { width:68px; min-height:94px; } }

.turn-banner { margin:14px 0; padding:14px 16px; border-radius:18px; font-size:20px; font-weight:900; text-align:center; border:2px solid #dbeafe; background:#eff6ff; color:#1d4ed8; }
.turn-banner.mine { background:linear-gradient(135deg,#d1fae5,#dbeafe); color:#065f46; border-color:#86efac; animation:pulseMine 1.3s infinite alternate; }
.turn-banner.other { background:#f8fafc; color:#475569; border-color:#e2e8f0; }
@keyframes pulseMine { from { transform:scale(1); } to { transform:scale(1.015); } }

.atom-counts { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:10px; }
.atom-count { --c:#ddd; background:linear-gradient(90deg,var(--c),#fff 42%); border:1px solid var(--line); border-radius:16px; padding:10px; display:grid; gap:2px; }
.atom-count b { font-size:24px; }
.atom-count span { font-weight:800; }
.atom-count small { color:#475569; font-weight:700; }

.public-bonds { display:grid; grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); gap:10px; }
.public-bond { background:#fff7ed; border:1px solid #fed7aa; border-radius:16px; padding:12px; display:grid; gap:3px; }
.public-bond strong { color:#c2410c; font-size:24px; }
.public-bond em { color:#db2777; font-style:normal; font-weight:900; }
.public-bond small { color:#64748b; font-weight:800; }

.card-float { position:fixed; left:50%; top:50%; transform:translate(-50%,-50%) scale(.65) rotate(-8deg); opacity:0; z-index:40; pointer-events:none; transition:.25s ease; display:grid; place-items:center; gap:10px; }
.card-float.show { opacity:1; transform:translate(-50%,-50%) scale(1) rotate(0); }
.float-label { background:#0f172a; color:white; padding:10px 14px; border-radius:999px; font-weight:900; box-shadow:0 10px 30px #0004; }
.card-back { background:linear-gradient(135deg,#1d4ed8,#06b6d4) !important; color:white; border-color:#fff; }
.new-card { animation:newCard .8s ease; }
@keyframes newCard { 0% { transform:translateY(-24px) rotate(-5deg); box-shadow:0 0 0 6px #fef08a; } 100% { transform:none; } }

.bond-flash { position:fixed; inset:0; display:grid; place-items:center; background:rgba(15,23,42,.22); backdrop-filter:blur(3px); z-index:45; opacity:0; pointer-events:none; transition:.2s ease; }
.bond-flash.show { opacity:1; }
.bond-flash-card { width:min(430px,92vw); background:white; border-radius:26px; padding:22px; text-align:center; box-shadow:0 25px 70px #0005; border:3px solid #fbbf24; transform:scale(.86); animation:bondPop .35s ease forwards; }
.big-formula { font-size:48px; font-weight:1000; color:#1d4ed8; line-height:1; }
.used-cards { display:flex; justify-content:center; gap:8px; flex-wrap:wrap; margin-top:10px; }
@keyframes bondPop { to { transform:scale(1); } }
