:root {
  --navy: #071b35;
  --navy-2: #0d2b50;
  --blue: #174b82;
  --orange: #f47b20;
  --orange-dark: #c94f08;
  --cream: #f5eee0;
  --paper: #fffaf0;
  --ink: #102033;
  --muted: #667487;
  --green: #35b879;
  --red: #dd4e4e;
  --shadow: 0 20px 50px rgba(2, 17, 37, .2);
  font-family: Inter, ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--navy); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at 20% -10%, #24669c 0, transparent 34rem), linear-gradient(160deg, #0b315a, var(--navy) 45%); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.noise { position: fixed; inset: 0; pointer-events: none; opacity: .055; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.topbar { position: relative; z-index: 2; max-width: 1080px; margin: auto; padding: 20px clamp(18px, 4vw, 42px); display: flex; justify-content: space-between; align-items: center; color: white; }
.brand { display: flex; gap: 10px; align-items: center; border: 0; background: transparent; color: white; font-size: 1.15rem; font-weight: 900; letter-spacing: .08em; }
.brand span { display: grid; place-items: center; width: 38px; height: 48px; border-radius: 7px; color: var(--navy); background: var(--cream); border: 3px solid var(--orange); transform: rotate(-4deg); box-shadow: 0 4px 0 rgba(0,0,0,.18); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.text-button, .lang { color: white; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); border-radius: 999px; padding: 10px 14px; font-weight: 700; }
.lang { min-width: 50px; }
main { position: relative; z-index: 1; max-width: 1080px; margin: auto; padding: clamp(12px, 3vw, 28px) clamp(18px, 4vw, 42px) 54px; }
main:focus { outline: none; }
.start-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(310px, .92fr); gap: clamp(22px, 5vw, 58px); align-items: center; min-height: calc(100vh - 150px); }
.intro { color: white; }
.eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: .78rem; font-weight: 900; color: #ffb06f; }
h1 { font-size: clamp(3.6rem, 9vw, 7rem); line-height: .88; margin: 14px 0 22px; letter-spacing: -.07em; }
.intro p { font-size: clamp(1.1rem, 2.2vw, 1.35rem); line-height: 1.55; color: #cfdded; max-width: 560px; }
.tile-row { display: flex; gap: 8px; margin-top: 30px; }
.mini-tile { width: 48px; height: 64px; background: var(--cream); border-radius: 7px; display: grid; place-items: center; font-size: 1.55rem; font-weight: 900; box-shadow: 0 7px 0 rgba(0,0,0,.15); transform: rotate(var(--r)); color: var(--c); }
.card { background: var(--paper); border: 1px solid rgba(255,255,255,.65); border-radius: 26px; padding: clamp(22px, 4vw, 34px); box-shadow: var(--shadow); }
.card h2, .card h3 { margin: 0 0 8px; }
.card > p { color: var(--muted); line-height: 1.5; margin: 0 0 24px; }
.stack { display: grid; gap: 12px; }
.primary, .secondary, .danger, .icon-button { min-height: 52px; border-radius: 14px; border: 0; font-weight: 850; transition: transform .15s, box-shadow .15s, background .15s; }
.primary { background: var(--orange); color: white; box-shadow: 0 5px 0 var(--orange-dark); padding: 0 20px; }
.primary:hover { background: #ff8730; transform: translateY(-1px); }
.primary:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--orange-dark); }
.secondary { background: #e8eef4; color: var(--navy); padding: 0 20px; }
.danger { background: #ffe9e6; color: #a72f2f; padding: 0 20px; }
.mode { text-align: left; padding: 18px; display: grid; grid-template-columns: 48px 1fr; gap: 14px; align-items: center; min-height: 88px; border: 2px solid #dfe6ee; border-radius: 16px; background: white; color: var(--ink); }
.mode:hover { border-color: var(--orange); }
.mode-icon { font-size: 1.65rem; }
.mode strong, .mode small { display: block; }
.mode small { color: var(--muted); margin-top: 4px; line-height: 1.35; }
.back { border: 0; background: transparent; color: var(--blue); font-weight: 800; padding: 0 0 20px; }
label { display: grid; gap: 7px; font-size: .9rem; font-weight: 800; }
input, select { width: 100%; min-height: 50px; border: 2px solid #dfe6ee; border-radius: 12px; background: white; color: var(--ink); padding: 11px 13px; font-size: 1rem; outline: none; }
input:focus, select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(244,123,32,.14); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.join-code { text-transform: uppercase; letter-spacing: .2em; font-weight: 900; text-align: center; font-size: 1.3rem; }
.shell { max-width: 760px; margin: 10px auto; }
.lobby-head, .game-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; color: white; margin: 18px 0 22px; }
.lobby-head h1, .game-head h1 { font-size: clamp(2.2rem, 6vw, 4.2rem); margin: 5px 0; }
.code-box { min-width: 150px; text-align: center; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); border-radius: 18px; padding: 13px 16px; }
.code-box small { display: block; color: #bcd0e4; font-weight: 700; }
.code-box strong { font-size: 1.7rem; letter-spacing: .16em; }
.players { display: grid; gap: 8px; margin: 18px 0; }
.player { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px; padding: 13px; background: white; border: 2px solid #e2e8ee; border-radius: 14px; }
.player.current { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(244,123,32,.12); }
.avatar { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--navy); color: white; font-weight: 900; }
.player small { color: var(--muted); }
.online { width: 9px; height: 9px; border-radius: 50%; background: #bbc5d0; }
.online.on { background: var(--green); }
.drag-controls { display: flex; gap: 5px; }
.icon-button { min-height: 36px; min-width: 38px; background: #edf1f5; color: var(--navy); }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 18px 0; }
.game-panel { background: var(--paper); border-radius: 28px; padding: clamp(20px, 4vw, 38px); text-align: center; box-shadow: var(--shadow); overflow: hidden; }
.round-label { color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-weight: 850; font-size: .8rem; }
.turn-name { font-size: clamp(2rem, 8vw, 4rem); margin: 10px 0 0; line-height: 1; }
.timer { width: min(68vw, 320px); aspect-ratio: 1; margin: 20px auto; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--orange) var(--progress), #dce4ea 0); position: relative; }
.timer::after { content: ""; position: absolute; inset: 14px; border-radius: 50%; background: var(--paper); }
.timer-value { z-index: 1; font-size: clamp(3.4rem, 15vw, 6rem); font-variant-numeric: tabular-nums; font-weight: 950; letter-spacing: -.06em; }
.timer.urgent { animation: pulse 1s infinite; background: conic-gradient(var(--red) var(--progress), #f2dcdc 0); }
@keyframes pulse { 50% { transform: scale(1.02); } }
.game-actions { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; max-width: 500px; margin: auto; }
.game-actions .wide { grid-column: 1 / -1; }
.status-note { min-height: 28px; color: var(--muted); margin: 0 0 16px; font-weight: 700; }
.score-strip { display: flex; gap: 8px; overflow-x: auto; margin-top: 18px; padding-bottom: 4px; }
.score-pill { flex: 1 0 120px; background: rgba(255,255,255,.1); color: white; border: 1px solid rgba(255,255,255,.17); border-radius: 13px; padding: 10px 12px; display: flex; justify-content: space-between; }
.draw-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 14px; margin: 12px 0 26px; }
.draw-player { display: grid; justify-items: center; gap: 12px; color: var(--muted); }
.draw-tile { width: 76px; height: 104px; display: grid; place-items: center; background: var(--cream); color: var(--navy); border: 4px solid #d9d0bf; border-radius: 10px; font-size: 2.4rem; font-weight: 950; box-shadow: 0 7px 0 #c9bfad; transform: rotate(-2deg); }
.draw-player.winner { color: var(--orange-dark); }
.draw-player.winner .draw-tile { border-color: var(--orange); box-shadow: 0 7px 0 var(--orange-dark), 0 0 0 5px rgba(244,123,32,.14); transform: translateY(-5px) rotate(3deg); }
.host-tools { margin-top: 12px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.host-tools button { border: 1px solid #dfe6ee; background: white; border-radius: 10px; padding: 9px 12px; color: var(--navy); font-weight: 750; }
.penalty { border: 3px solid var(--red); background: #fff5f3; }
.penalty-mark { font-size: 3.6rem; }
.score-form { display: grid; gap: 12px; margin: 20px 0; text-align: left; }
.score-row { display: grid; grid-template-columns: 1fr 120px; align-items: center; gap: 12px; }
.scoreboard { width: 100%; border-collapse: collapse; margin: 22px 0; }
.scoreboard th, .scoreboard td { padding: 12px 8px; border-bottom: 1px solid #e1e6eb; text-align: left; }
.scoreboard th:last-child, .scoreboard td:last-child { text-align: right; }
.rules { max-width: 780px; margin: 10px auto; }
.rules .card { margin-bottom: 14px; }
.rules h1 { color: white; font-size: clamp(2.5rem, 7vw, 4.5rem); margin: 14px 0 28px; }
.rules h2 { display: flex; gap: 10px; align-items: center; }
.rules p, .rules li { color: #526175; line-height: 1.62; }
.rules li + li { margin-top: 7px; }
.callout { padding: 16px; border-left: 4px solid var(--orange); background: #fff2e8; border-radius: 10px; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 24px; transform: translate(-50%, 120px); opacity: 0; background: #0d1725; color: white; border-radius: 12px; padding: 12px 18px; font-weight: 750; transition: .25s; box-shadow: var(--shadow); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.empty { color: var(--muted); text-align: center; padding: 18px; border: 2px dashed #d8e0e8; border-radius: 14px; }
@media (max-width: 720px) {
  .start-grid { grid-template-columns: 1fr; align-content: start; min-height: auto; padding-top: 22px; }
  .intro h1 { font-size: 4.5rem; }
  .intro p { font-size: 1.05rem; }
  .tile-row { display: none; }
  .lobby-head, .game-head { align-items: stretch; flex-direction: column; }
  .code-box { display: flex; justify-content: space-between; align-items: center; }
  .form-grid { grid-template-columns: 1fr; }
  .game-actions { grid-template-columns: 1fr; }
  .game-actions .wide { grid-column: auto; }
  .score-row { grid-template-columns: 1fr 96px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
