:root {
  --cream: #f4ead8;
  --walnut: #5a3a24;
  --bordo: #7a2331;
  --green: #2f4a3a;
  --brass: #c8a25a;
  --card: rgba(36, 24, 17, .94);
  --line: rgba(200, 162, 90, .35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b1410; font-family: -apple-system, "Segoe UI", system-ui, sans-serif; color: var(--cream); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
.off { display: none !important; }
.hidden { opacity: 0; pointer-events: none; }

#app { position: fixed; inset: 0; }
#app canvas { display: block; }
#css3d, #labels { position: fixed; inset: 0; pointer-events: none; }
#css3d iframe { border: 0; background: #000; }
#labels { z-index: 2; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#crosshair { position: fixed; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: rgba(255, 244, 225, .8); box-shadow: 0 0 4px rgba(0,0,0,.6); }
.pill { padding: 7px 14px; border-radius: 999px; background: rgba(30, 20, 14, .72); border: 1px solid var(--line); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#prompt { position: fixed; left: 50%; top: 58%; transform: translateX(-50%); font-size: 15px; transition: opacity .2s; }
#prompt b { color: var(--brass); }
#zone { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); font-size: 14px; letter-spacing: .04em; transition: opacity .6s; }
#toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); font-size: 15px; transition: opacity .4s; max-width: 90vw; text-align: center; }
#presence { position: fixed; right: 16px; top: 16px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; font-size: 13px; }
#presence .who { display: flex; align-items: center; gap: 8px; }
#presence .dot { width: 9px; height: 9px; border-radius: 50%; background: #6b5e54; }
#presence .on .dot { background: #7ed38a; box-shadow: 0 0 8px #7ed38a; }
#chatlog { position: fixed; left: 16px; bottom: 64px; width: min(380px, 70vw); display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
#chatlog .msg { padding: 6px 11px; border-radius: 12px; background: rgba(30, 20, 14, .66); align-self: flex-start; max-width: 100%; word-wrap: break-word; transition: opacity 1s; }
#chatlog .msg b { color: var(--brass); margin-right: 6px; }
#chatlog .msg.fade { opacity: 0; }
#hud.chatting #chatlog .msg.fade { opacity: 1; }
#chatform { position: fixed; left: 16px; bottom: 16px; width: min(380px, 70vw); pointer-events: auto; }
#chatinput { width: 100%; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: rgba(30, 20, 14, .88); outline: none; }
#emotebar { position: fixed; right: 16px; bottom: 16px; display: flex; gap: 4px; pointer-events: auto; }
#emotebar button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: rgba(30, 20, 14, .66); font-size: 18px; cursor: pointer; }
#emotebar button:hover { background: rgba(122, 35, 49, .7); }

/* 3B üstündeki etiketler */
.nametag { padding: 3px 10px; border-radius: 999px; background: rgba(30, 20, 14, .7); font-size: 13px; color: var(--cream); white-space: nowrap; border: 1px solid var(--line); }
.bubble { padding: 6px 12px; border-radius: 14px; background: #fffaf0; color: #2b1d14; font-size: 15px; max-width: 220px; text-align: center; box-shadow: 0 4px 14px rgba(0,0,0,.3); transition: opacity .4s, transform .4s; }
.bubble.big { font-size: 34px; background: transparent; box-shadow: none; padding: 0; }
.bubble.hide { opacity: 0; transform: translateY(8px); }

/* ---------- Ekranlar ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(52, 32, 20, .6), rgba(15, 10, 8, .9)); z-index: 10; padding: 16px; }
#login { background: radial-gradient(ellipse at 50% 30%, #4a2c1c, #160f0b 75%); }
.card { width: min(440px, 94vw); padding: 28px 30px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 24px 70px rgba(0,0,0,.55); text-align: center; max-height: 94vh; overflow: auto; }
.card h1 { margin: 0 0 4px; font-size: 32px; font-weight: 600; letter-spacing: .02em; }
.sub { margin: 4px 0 18px; opacity: .72; font-size: 14px; }
.note { font-size: 13px; opacity: .75; margin: 0 0 10px; }
.err { color: #ff9c8a; min-height: 1.2em; font-size: 14px; margin: 10px 0 0; }
.users { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.users button { padding: 20px 8px 16px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255,255,255,.04); cursor: pointer; transition: transform .15s, background .15s; }
.users button:hover { transform: translateY(-2px); background: rgba(122, 35, 49, .35); }
.users .face { font-size: 46px; display: block; margin-bottom: 6px; }
.users .nm { font-size: 18px; font-weight: 600; }
.users .st { display: block; font-size: 12px; opacity: .6; margin-top: 4px; }
form input, form select, .panel input, .panel select, .panel textarea { width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: #2a1c14; margin: 6px 0; outline: none; }
form input:focus, .panel input:focus, .panel textarea:focus { border-color: var(--brass); }
button.primary, form button[type=submit] { padding: 12px 34px; border: 0; border-radius: 999px; background: var(--bordo); color: var(--cream); cursor: pointer; box-shadow: 0 6px 18px rgba(122, 35, 49, .45); margin-top: 8px; }
button.primary:hover, form button[type=submit]:hover { background: #8d2a3a; }
button.link { background: none; border: 0; color: var(--brass); cursor: pointer; margin-top: 12px; font-size: 13px; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 20px 0 14px; font-size: 13px; text-align: left; opacity: .85; }
.keys b { display: inline-block; min-width: 64px; color: var(--brass); font-weight: 600; }
.settings { font-size: 13px; opacity: .9; display: grid; gap: 10px; }
.settings select { margin-left: 8px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: #2a1c14; width: auto; }
.sounds { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.sounds input { width: auto; margin: 0 3px 0 0; }

/* ---------- Panel ---------- */
#panel { position: fixed; z-index: 8; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(620px, 95vw); max-height: 88vh; display: flex; flex-direction: column; border-radius: 18px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 24px 70px rgba(0,0,0,.6); }
#panel.side { left: auto; right: 16px; top: 16px; bottom: 16px; transform: none; width: min(400px, 92vw); max-height: none; background: rgba(30, 20, 14, .9); }
#panel.wide { width: min(1100px, 96vw); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
#panelClose { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: transparent; cursor: pointer; }
#panelBody { padding: 16px 18px; overflow: auto; }
.panel { font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input, .row > select { flex: 1; }
.btn { padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.05); cursor: pointer; white-space: nowrap; }
.btn:hover { background: rgba(122, 35, 49, .45); }
.btn.main { background: var(--bordo); border-color: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: default; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs .btn.on { background: var(--green); border-color: var(--brass); }
.list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.item { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid transparent; }
.item.cur { border-color: var(--brass); background: rgba(200, 162, 90, .12); }
.item.drag-over { border-color: #7ed38a; }
.item img { width: 88px; height: 50px; object-fit: cover; border-radius: 8px; flex: none; }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t small { opacity: .6; }
.item .acts { display: flex; gap: 4px; }
.muted { opacity: .6; font-size: 13px; }
.controls { display: flex; gap: 6px; justify-content: center; margin: 10px 0; }
.controls .btn { font-size: 18px; padding: 8px 14px; }
input[type=range] { width: 100%; accent-color: var(--brass); padding: 0; }
.score { display: flex; justify-content: space-around; padding: 10px; border-radius: 12px; background: rgba(255,255,255,.05); margin-bottom: 12px; }
.score b { font-size: 22px; color: var(--brass); display: block; text-align: center; }
.big-card { padding: 28px 20px; border-radius: 16px; background: linear-gradient(135deg, #7a2331, #4b1520); font-size: 21px; text-align: center; line-height: 1.4; margin: 10px 0; box-shadow: inset 0 0 0 2px rgba(200,162,90,.4); animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.6) rotate(-4deg); opacity: 0; } }
.grid-xox { display: grid; grid-template-columns: repeat(3, 90px); gap: 6px; justify-content: center; margin: 12px 0; }
.grid-xox button { height: 90px; font-size: 44px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.05); cursor: pointer; }
.grid-c4 { display: grid; grid-template-columns: repeat(7, 46px); gap: 5px; justify-content: center; padding: 10px; border-radius: 14px; background: #24476b; margin: 12px auto; width: max-content; }
.grid-c4 button { width: 46px; height: 46px; border-radius: 50%; border: 0; background: #12263b; cursor: pointer; }
.grid-c4 button.f { background: #e07a5f; } .grid-c4 button.m { background: #f2cc8f; }
.grid-xox button.win, .grid-c4 button.win { box-shadow: 0 0 0 3px #7ed38a; }
.board-wrap { position: relative; border-radius: 12px; overflow: hidden; border: 6px solid #8a5a35; touch-action: none; }
.board-wrap canvas { width: 100%; display: block; cursor: crosshair; touch-action: none; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatches button.on { border-color: #fff; }
.mem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.polaroid { background: #fbf6ec; color: #2b1d14; padding: 8px 8px 10px; border-radius: 4px; box-shadow: 0 6px 16px rgba(0,0,0,.35); font-size: 12px; position: relative; }
.polaroid img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.polaroid .d { font-weight: 600; margin-top: 6px; }
.polaroid .x { position: absolute; top: 4px; right: 4px; }
textarea { min-height: 80px; resize: vertical; }
.cap { padding: 12px; border-radius: 12px; background: rgba(255,255,255,.05); margin-top: 8px; }
.cap.locked { opacity: .8; }
.cap .when { font-size: 12px; opacity: .65; }

/* ---------- Günün sürprizi ---------- */
#daily { position: fixed; inset: 0; z-index: 9; display: grid; place-items: center; background: rgba(15,10,8,.55); }
.daily-card { position: relative; width: min(420px, 90vw); padding: 30px 26px; border-radius: 22px; text-align: center; background: linear-gradient(160deg, #f6efe2, #f2cc8f); color: #3a2516; box-shadow: 0 30px 80px rgba(0,0,0,.5); animation: pop .7s cubic-bezier(.2, 1.6, .4, 1); overflow: hidden; }
.daily-card h3 { margin: 0 0 10px; font-size: 24px; }
.daily-card p { font-size: 19px; line-height: 1.45; }
.daily-card button { padding: 10px 26px; border-radius: 999px; border: 0; background: var(--bordo); color: var(--cream); cursor: pointer; }
.confetti { position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(#e07a5f 2px, transparent 3px), radial-gradient(#81b29a 2px, transparent 3px), radial-gradient(#3d8bb5 2px, transparent 3px), radial-gradient(#c9748f 2px, transparent 3px); background-size: 60px 60px, 80px 80px, 70px 70px, 90px 90px; background-position: 0 0, 20px 30px, 40px 10px, 10px 50px; animation: fall 3s linear infinite; opacity: .7; }
@keyframes fall { to { background-position: 0 120px, 20px 190px, 40px 150px, 10px 230px; } }

/* ---------- Mobil ---------- */
#touch { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
#joy { position: fixed; left: 24px; bottom: 28px; width: 130px; height: 130px; border-radius: 50%; background: rgba(30,20,14,.35); border: 1px solid var(--line); pointer-events: auto; touch-action: none; }
#joyKnob { position: absolute; left: 40px; top: 40px; width: 50px; height: 50px; border-radius: 50%; background: rgba(244, 234, 216, .55); }
.tbtns { position: fixed; right: 18px; bottom: 80px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; pointer-events: auto; }
.tbtns button { width: 58px; height: 58px; border-radius: 50%; border: 1px solid var(--line); background: rgba(30,20,14,.55); font-size: 20px; font-weight: 700; touch-action: manipulation; }
body.touch #crosshair { display: none; }
body.touch #emotebar { bottom: 16px; right: 50%; transform: translateX(50%); }
body.touch #chatlog { bottom: 170px; }
body.touch #prompt { top: 40%; }
#css3d * { pointer-events: none !important; }
