:root {
  --bg: #16261f; --bg2: #1d3329; --panel: #213a2f; --line: rgba(255,255,255,.12); --text: #f3f1e7; --muted: #a9bcb0;
  --chalk: #ffe66d; --ok: #7ff0a8; --bad: #ff9e8a; --wood: #8a5a33; --wood2: #6d4424; --board: #23493a;
  --hand: 'Patrick Hand', 'Comic Sans MS', 'Segoe Print', cursive;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; overflow: hidden; -webkit-tap-highlight-color: transparent;
  background-image: radial-gradient(900px 600px at 80% -10%, rgba(255,230,109,.08), transparent 60%), radial-gradient(700px 500px at 0% 100%, rgba(111,227,161,.08), transparent 60%); }
button, input, select { font: inherit; color: inherit; }
.screen { position: fixed; inset: 0; }

/* ---------- düğmeler ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.08); font-weight: 700; cursor: pointer; transition: transform .12s, background .15s; }
.btn:hover { background: rgba(255,255,255,.14); } .btn:active { transform: scale(.97); }
.btn.primary { background: var(--chalk); color: #23301f; border-color: transparent; box-shadow: 0 4px 0 #c9b03f; }
.btn.primary:hover { background: #fff08f; } .btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #c9b03f; }
.btn[disabled] { opacity: .5; pointer-events: none; }
:focus-visible { outline: 3px solid var(--chalk); outline-offset: 2px; }

/* ---------- giriş ekranı ---------- */
#home { display: grid; place-items: center; padding: 16px; overflow: auto; }
.home-card { position: relative; width: min(420px, 100%); padding: 34px 26px 22px; border-radius: 26px; text-align: center; background: var(--board); border: 12px solid var(--wood); box-shadow: inset 0 0 0 2px var(--wood2), inset 0 0 60px rgba(0,0,0,.35), 0 30px 70px rgba(0,0,0,.5);
  background-image: radial-gradient(circle at 20% 30%, rgba(255,255,255,.06), transparent 40%), radial-gradient(circle at 80% 70%, rgba(255,255,255,.05), transparent 45%); }
.back { position: absolute; left: 14px; top: 10px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; }
.back:hover { color: var(--text); }
.logo { margin: 6px 0 0; font: 400 76px/1 var(--hand); letter-spacing: 1px; }
.logo span { display: inline-block; animation: wob 2.6s ease-in-out infinite; }
.logo span:nth-child(1) { color: #ffe66d; } .logo span:nth-child(2) { color: #ff8fc7; animation-delay: .15s; } .logo span:nth-child(3) { color: #7fe3ff; animation-delay: .3s; }
.logo span:nth-child(4) { color: #6fe3a1; animation-delay: .45s; } .logo span:nth-child(5) { color: #ffb347; animation-delay: .6s; } .logo span:nth-child(6) { color: #c79bff; animation-delay: .75s; }
.logo i { font-style: normal; color: #fff; display: inline-block; transform: rotate(12deg); margin-left: 4px; }
@keyframes wob { 50% { transform: translateY(-6px) rotate(-3deg); } }
.tagline { margin: 4px 0 22px; font: 400 21px/1.2 var(--hand); color: var(--text); opacity: .9; }
.me { display: flex; gap: 10px; margin-bottom: 12px; }
.ava { flex: none; width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--c, #ffe66d); background: rgba(0,0,0,.25); font-size: 26px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0; }
.me input, .joinrow input { flex: 1; min-width: 0; min-height: 52px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0,0,0,.28); font-size: 18px; }
.me input:focus, .joinrow input:focus, #sayIn:focus { outline: none; border-color: var(--chalk); box-shadow: 0 0 0 4px rgba(255,230,109,.18); }
.ava-pick { margin-bottom: 12px; padding: 10px; border-radius: 14px; background: rgba(0,0,0,.22); }
.ava-pick .row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.ava-pick .row + .row { margin-top: 8px; }
.ava-pick button { width: 38px; height: 38px; border-radius: 50%; border: 2px solid transparent; background: rgba(255,255,255,.07); font-size: 20px; cursor: pointer; padding: 0; }
.ava-pick button.on { border-color: #fff; } .ava-pick button.col { background: var(--c); width: 28px; height: 28px; }
#btnCreate { width: 100%; min-height: 54px; font-size: 18px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 16px 0 10px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.joinrow { display: flex; gap: 8px; }
.joinrow input { text-align: center; text-transform: uppercase; letter-spacing: .3em; font: 700 22px/1 ui-monospace, Consolas, monospace; }
#homeMsg { min-height: 20px; margin: 10px 0 0; color: var(--bad); font-size: 14px; }
.fine { margin: 8px 0 0; color: var(--muted); font-size: 12.5px; }

/* ---------- oyun düzeni ---------- */
#game { display: grid; grid-template-columns: 220px minmax(0, 1fr) 300px; grid-template-rows: auto minmax(0, 1fr); grid-template-areas: 'bar bar bar' 'players stage chat'; gap: 10px; padding: 10px; padding-top: calc(10px + env(safe-area-inset-top)); padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.bar { grid-area: bar; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.brand { font: 400 28px/1 var(--hand); color: var(--chalk); text-decoration: none; flex: none; } .brand i { font-style: normal; color: #fff; }
.chip { flex: none; min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px dashed rgba(255,255,255,.35); background: rgba(0,0,0,.2); font: 700 15px/1 ui-monospace, Consolas, monospace; letter-spacing: .12em; cursor: pointer; }
.chip:hover { background: rgba(255,255,255,.1); }
.word { flex: 1; min-width: 0; text-align: center; font: 400 30px/1 var(--hand); letter-spacing: .14em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.word small { font: 600 12px/1 system-ui, sans-serif; letter-spacing: 0; color: var(--muted); margin-left: 8px; vertical-align: middle; }
.word.mine { color: var(--chalk); letter-spacing: .04em; }
.round { flex: none; color: var(--muted); font-weight: 700; font-size: 13px; white-space: nowrap; }
.timer { position: relative; flex: none; width: 42px; height: 42px; display: grid; place-items: center; }
.timer svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer circle { fill: none; stroke: rgba(255,255,255,.14); stroke-width: 4; }
#tRing { stroke: var(--chalk); stroke-linecap: round; stroke-dasharray: 106.8; transition: stroke-dashoffset .3s linear, stroke .3s; }
.timer b { position: relative; font-size: 14px; font-variant-numeric: tabular-nums; }
.timer.low #tRing { stroke: var(--bad); } .timer.low b { color: var(--bad); animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.18); } }

.players { grid-area: players; display: flex; flex-direction: column; gap: 6px; overflow: auto; padding: 8px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.pl { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 12px; background: rgba(0,0,0,.18); border: 1px solid transparent; transition: background .2s, border-color .2s; }
.pl.me { border-color: rgba(255,255,255,.22); } .pl.ok { background: rgba(127,240,168,.16); border-color: rgba(127,240,168,.5); } .pl.off { opacity: .45; }
.pl .av { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--c); display: grid; place-items: center; font-size: 18px; background: rgba(0,0,0,.25); }
.pl .nm { flex: 1; min-width: 0; } .pl .nm b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .pl .nm small { color: var(--muted); font-size: 12px; }
.pl .tag { flex: none; font-size: 16px; } .pl .rank { flex: none; width: 18px; color: var(--muted); font-weight: 700; font-size: 12px; text-align: center; }

.stage { grid-area: stage; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-width: 0; min-height: 0; }
.board { position: relative; width: 100%; max-width: calc((100dvh - 190px) * 4 / 3); aspect-ratio: 4 / 3; border-radius: 14px; background: var(--board); border: 10px solid var(--wood); box-shadow: inset 0 0 0 2px var(--wood2), inset 0 0 80px rgba(0,0,0,.35), 0 18px 40px rgba(0,0,0,.4);
  background-image: radial-gradient(circle at 25% 20%, rgba(255,255,255,.07), transparent 38%), radial-gradient(circle at 75% 80%, rgba(255,255,255,.05), transparent 42%), linear-gradient(100deg, rgba(255,255,255,.03) 0 12%, transparent 12% 40%, rgba(255,255,255,.025) 40% 55%, transparent 55%); }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; border-radius: 5px; }
.board.draw #cv { cursor: crosshair; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 14px; text-align: center; overflow: auto; background: rgba(20,40,32,.72); border-radius: 5px; backdrop-filter: blur(1px); }
.overlay:empty { display: none; }
.ov { width: min(460px, 100%); animation: ovin .35s cubic-bezier(.2,.8,.2,1); }
@keyframes ovin { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.ov h2 { margin: 0 0 6px; font: 400 clamp(26px, 5vw, 40px)/1.1 var(--hand); color: var(--chalk); }
.ov p { margin: 0 0 12px; color: var(--text); opacity: .92; }
.ov .big { font: 400 clamp(34px, 8vw, 62px)/1 var(--hand); letter-spacing: .2em; color: #fff; margin: 4px 0 10px; }
.ov .row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 12px; }
.codeline { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px; margin-bottom: 10px; }
.codeline span { color: var(--muted); font-weight: 700; font-size: 13px; }
.codeline b { font: 400 clamp(34px, 7vw, 54px)/1 var(--hand); letter-spacing: .18em; color: var(--chalk); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.opt { flex: 1 1 120px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 12px; background: rgba(0,0,0,.25); text-align: left; font-weight: 600; font-size: 14px; }
.opt.wide { flex-basis: 100%; }
.ov .hint { font-size: 13px; color: var(--muted); margin: 0; }
.ov .row:last-child { margin-bottom: 0; }
.opt select { min-height: 34px; max-width: 100%; padding: 0 6px; border-radius: 10px; border: 1px solid var(--line); background: #1a3027; font-weight: 700; }
.opt span.v { color: var(--chalk); font-weight: 700; }
.pickw { min-height: 58px; padding: 0 20px; font: 400 26px/1 var(--hand); border-radius: 16px; border: 2px dashed rgba(255,255,255,.55); background: rgba(0,0,0,.25); cursor: pointer; transition: transform .12s, background .15s, border-color .15s; }
.pickw:hover { background: rgba(255,230,109,.18); border-color: var(--chalk); transform: translateY(-2px) rotate(-1deg); }
.gain { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 10px; background: rgba(0,0,0,.22); margin-bottom: 4px; text-align: left; }
.gain b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .gain span { color: var(--ok); font-weight: 800; } .gain span.z { color: var(--muted); }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 10px 0 12px; }
.pod { width: 30%; max-width: 120px; } .pod .av { font-size: 30px; } .pod b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .pod small { color: var(--chalk); font-weight: 800; }
.pod i { display: grid; place-items: center; margin-top: 4px; border-radius: 10px 10px 0 0; background: rgba(255,230,109,.22); border: 2px dashed rgba(255,230,109,.6); border-bottom: 0; font: 400 26px/1 var(--hand); font-style: normal; animation: grow .7s cubic-bezier(.2,.8,.2,1) backwards; transform-origin: bottom; }
.pod.p1 i { height: 84px; } .pod.p2 i { height: 60px; animation-delay: .12s; } .pod.p3 i { height: 42px; animation-delay: .24s; }
@keyframes grow { from { transform: scaleY(0); } }

.tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px; padding: 6px 10px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); max-width: 100%; }
.tools .grp { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; justify-content: center; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); background: var(--c); cursor: pointer; padding: 0; transition: transform .1s; }
.sw.on { border-color: #fff; transform: scale(1.18); box-shadow: 0 0 0 2px rgba(0,0,0,.4); }
.tb { min-width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,.2); cursor: pointer; display: grid; place-items: center; font-size: 18px; padding: 0 8px; }
.tb.on { background: rgba(255,230,109,.22); border-color: var(--chalk); } .tb i { display: block; border-radius: 50%; background: #fff; }

.chat { grid-area: chat; display: flex; flex-direction: column; min-height: 0; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
.log { flex: 1; min-height: 0; overflow: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; overscroll-behavior: contain; }
.log div { padding: 3px 8px; border-radius: 9px; overflow-wrap: anywhere; font-size: 14.5px; }
.log b { font-weight: 700; margin-right: 4px; }
.log .sys { color: var(--muted); font-size: 13px; } .log .big { color: var(--chalk); font-weight: 700; }
.log .ok { background: rgba(127,240,168,.18); color: var(--ok); font-weight: 700; } .log .close { background: rgba(255,230,109,.16); color: var(--chalk); }
.log .in { color: #9fd9b6; font-style: italic; }
#say { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
#sayIn { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,.28); font-size: 16px; }
#say .btn { min-height: 44px; padding: 0 14px; }
.net { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 50; padding: 10px 16px; border-radius: 12px; background: #5a2a22; border: 1px solid var(--bad); font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; padding: 10px 16px; border-radius: 12px; background: #173a2a; border: 1px solid rgba(127,240,168,.5); font-weight: 700; animation: ovin .3s; }

/* ---------- tablet / telefon: tahta üstte, sohbet altta ---------- */
@media (max-width: 1100px) {
  #game { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto minmax(110px, 1fr); grid-template-areas: 'bar' 'players' 'stage' 'chat'; gap: 6px; padding: 6px; padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .bar { padding: 6px 8px; gap: 6px; border-radius: 12px; } .brand { font-size: 22px; } .round { font-size: 12px; } .word { font-size: 24px; } .word small { display: none; }
  .chip { min-height: 32px; padding: 0 8px; font-size: 13px; } .timer { width: 36px; height: 36px; } .timer b { font-size: 12px; }
  .players { flex-direction: row; padding: 5px; gap: 5px; border-radius: 12px; overflow-x: auto; overflow-y: hidden; }
  .pl { flex: none; padding: 3px 8px 3px 4px; gap: 5px; } .pl .av { width: 26px; height: 26px; font-size: 14px; } .pl .nm b { font-size: 12.5px; max-width: 74px; } .pl .nm small { font-size: 11px; } .pl .rank { display: none; }
  .stage { justify-content: flex-start; gap: 5px; }
  .board { border-width: 6px; max-width: min(100%, calc((100dvh - 330px) * 4 / 3)); }
  .tools { padding: 4px 6px; gap: 4px 8px; border-radius: 12px; } .sw { width: 24px; height: 24px; } .tb { min-width: 34px; height: 34px; font-size: 16px; }
  .chat { border-radius: 12px; } .log div { font-size: 13.5px; }
  .pickw { min-height: 48px; font-size: 22px; padding: 0 14px; }
}
@media (max-width: 420px) { .brand { display: none; } .logo { font-size: 62px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
