* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #050505;
  font-family: 'Pixelify Sans', 'Trebuchet MS', system-ui, sans-serif; color: #d8d0c0;
  touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none;
}
:root { --slot: min(56px, calc((100vw - 60px) / 5.6)); --bg: rgba(14, 12, 11, 0.86); --bd: #3a2a24; --red: #8a1a1a; }
canvas#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; background: #000; }
canvas#game { position: fixed; inset: 0; display: block; cursor: crosshair; background: transparent; }
[hidden] { display: none !important; }

.panel { background: var(--bg); border: 2px solid var(--bd); border-radius: 6px; box-shadow: 0 2px 10px rgba(0,0,0,.6); }
.panel.small { padding: 4px 8px; font-size: 13px; }
.btn {
  font-family: inherit; font-size: 15px; color: #e8dcc8; cursor: pointer;
  background: linear-gradient(#3a2e2a, #241c1a); border: 2px solid #5a4038; border-radius: 5px;
  padding: 6px 12px; box-shadow: 0 2px 0 #120c0a;
}
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.big { font-size: 19px; padding: 10px 18px; width: 100%; margin-top: 10px; }
.btn.sm { font-size: 13px; padding: 4px 8px; }
.btn.sq { width: 34px; height: 34px; padding: 0; font-size: 15px; }
.btn.round { width: 46px; height: 46px; border-radius: 50%; padding: 0; font-size: 20px; }
.btn.red { background: linear-gradient(#8a1e1a, #5a100e); border-color: #b02a24; color: #fff; }
.btn.green { background: linear-gradient(#3a5a2a, #24381a); border-color: #4a7a3a; }
.btn:disabled { opacity: .4; }

/* giriş */
#login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 50; padding: 12px;
  background: radial-gradient(ellipse at 50% 40%, #2a1210 0%, #0a0606 60%, #000 100%); overflow-y: auto; touch-action: pan-y; }
.card { background: rgba(16,12,11,.95); border: 2px solid #4a2a24; border-radius: 10px; padding: 20px; width: min(380px, 100%); text-align: center;
  box-shadow: 0 0 40px rgba(140,20,20,.25); max-height: 100%; overflow-y: auto; }
.card.wide { width: min(780px, 100%); }
.card h1 { margin: 0; font-family: 'Creepster', 'Pixelify Sans', cursive; font-size: 48px; color: #a81e1a; letter-spacing: 3px; text-shadow: 0 0 18px rgba(200,20,20,.5); font-weight: 400; }
.card .sub { margin: 2px 0 16px; color: #8a7a6a; font-style: italic; }
.card label { display: block; text-align: left; margin: 8px 0 4px; }
.card input { width: 100%; font: inherit; font-size: 18px; padding: 10px; border: 2px solid #4a3a34; border-radius: 6px; background: #0e0a09; color: #e8dcc8; outline: none; }
.hint { font-size: 13px; opacity: .6; margin: 10px 0 0; }
.err { color: #e04a3a; min-height: 1em; margin: 10px 0 0; }
.creator { display: flex; gap: 14px; text-align: left; }
.prevBox { display: flex; flex-direction: column; align-items: center; gap: 6px; flex-shrink: 0; }
#prevHold canvas, #eqPrev canvas { display: block; width: 220px; height: 308px; background: radial-gradient(ellipse at 50% 60%, #3a2a24, #0e0a09 75%); border: 2px solid #4a3a34; border-radius: 8px; touch-action: none; cursor: grab; }
#eqPrev canvas { width: 90px; height: 127px; border-width: 1px; }
.prevBox .row { display: flex; gap: 4px; }
.optsBox { flex: 1; min-width: 0; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs span { padding: 5px 10px; border: 2px solid #4a3a34; border-radius: 5px; cursor: pointer; font-size: 14px; background: #1a1412; }
.tabs span.on { background: #5a1a16; border-color: #a83a2a; color: #fff; }
#charOpts { max-height: 330px; overflow-y: auto; touch-action: pan-y; padding-right: 4px; }
.optRow { margin-bottom: 9px; font-size: 13px; color: #a89a8a; }
.optRow label { display: block; margin: 0 0 2px; text-align: left; }
.optRow .sws { display: flex; flex-wrap: wrap; }
.optRow .sw { display: inline-block; width: 28px; height: 28px; border: 2px solid #2a201c; border-radius: 4px; margin: 2px; cursor: pointer; vertical-align: middle; }
.optRow .sw.on { outline: 2px solid #e8dcc8; outline-offset: 1px; }
.optRow .txt { display: inline-block; padding: 5px 9px; border: 2px solid #3a2e2a; border-radius: 4px; margin: 2px; cursor: pointer; background: #1a1412; color: #d8d0c0; font-size: 13px; }
.optRow .txt.on { background: #5a1a16; border-color: #a83a2a; }
.prof { border: 2px solid #3a2e2a; border-radius: 6px; padding: 6px 8px; margin-bottom: 6px; cursor: pointer; background: #1a1412; }
.prof.on { border-color: #a83a2a; background: #2a1210; }
.prof b { color: #e8dcc8; } .prof span { font-size: 12px; color: #9a8a7a; }

/* HUD */
#bars { position: fixed; top: calc(8px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); padding: 6px 8px; width: 180px; z-index: 5; }
.bar { display: flex; align-items: center; gap: 5px; height: 15px; margin: 2px 0; font-size: 11px; }
.bar i { font-style: normal; width: 14px; text-align: center; font-size: 11px; }
.bar div { flex: 1; height: 8px; background: #1a1412; border: 1px solid #000; border-radius: 2px; overflow: hidden; }
.bar b { display: block; height: 100%; width: 50%; transition: width .3s; }
.bar span { width: 26px; text-align: right; color: #a89a8a; }
#topLeft2 { position: fixed; top: calc(122px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); z-index: 5; display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
#topLeft2 .row { display: flex; gap: 3px; }
#clock { position: fixed; top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); padding: 5px 10px; text-align: right; z-index: 5; min-width: 130px; }
#timeTxt { font-size: 18px; font-weight: 600; }
#timeTxt.night { color: #c84a3a; }
#killTxt { font-size: 13px; color: #9a8a7a; }
#minimap { position: fixed; top: calc(84px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); width: 130px; height: 130px; border: 2px solid var(--bd); border-radius: 6px; z-index: 5; background: #000; image-rendering: pixelated; cursor: pointer; }
#chatLog { position: fixed; left: calc(8px + env(safe-area-inset-left)); bottom: calc(var(--slot) + 70px + env(safe-area-inset-bottom)); max-width: min(55vw, 380px); z-index: 4; pointer-events: none; font-size: 13px; }
#chatLog div { background: rgba(10,8,8,.7); padding: 3px 8px; border-radius: 4px; margin-top: 3px; transition: opacity 1s; }
#chatLog div.sys { color: #c8a080; font-style: italic; }
#chatLog div.old { opacity: 0; }
#chatLog b { color: #e87a7a; }
#warn { position: fixed; top: 22%; left: 0; right: 0; text-align: center; z-index: 6; pointer-events: none; font-family: 'Creepster', 'Pixelify Sans', cursive; font-size: clamp(22px, 4.5vw, 40px); color: #c82a20; text-shadow: 0 0 14px #000, 0 0 4px #000; opacity: 0; transition: opacity 1.2s; letter-spacing: 1px; padding: 0 10px; }
#warn.on { opacity: 1; }
#prompt { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--slot) + 52px + env(safe-area-inset-bottom)); z-index: 5; pointer-events: none; font-size: 15px; background: rgba(10,8,8,.75); padding: 4px 12px; border-radius: 5px; border: 1px solid #3a2a24; white-space: nowrap; }
#prompt:empty { display: none; }
#prompt b { color: #e8c060; }
#progress { position: fixed; left: 50%; top: 58%; transform: translateX(-50%); width: 160px; height: 14px; background: #1a1412; border: 2px solid #4a3a34; border-radius: 4px; z-index: 6; overflow: hidden; }
#progFill { height: 100%; width: 0; background: #a8842a; }
#progTxt { position: absolute; inset: 0; font-size: 11px; text-align: center; line-height: 11px; color: #fff; text-shadow: 0 1px 1px #000; }

#hotwrap { position: fixed; bottom: calc(6px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 4px; }
#weapon { font-size: 14px; background: rgba(10,8,8,.75); padding: 2px 10px; border-radius: 4px; border: 1px solid #3a2a24; white-space: nowrap; }
#weapon:empty { display: none; }
#weapon .am { color: #e8c060; font-weight: 600; }
#weapon .low { color: #e04a3a; }
#hotbar { display: flex; gap: 3px; padding: 3px; background: rgba(10,8,8,.8); border: 2px solid var(--bd); border-radius: 6px; }
.slot { width: var(--slot); height: var(--slot); background: #1a1412; border: 2px solid #3a2e2a; border-radius: 4px; position: relative; cursor: pointer; flex-shrink: 0; }
.slot.sel { border-color: #c8a040; box-shadow: inset 0 0 0 1px #c8a040; background: #2a2018; }
.slot.pick { border-color: #c84a3a; background: #2a1412; }
.slot.empty { opacity: .5; }
.slot img { position: absolute; left: 8%; top: 8%; width: 84%; height: 84%; image-rendering: pixelated; pointer-events: none; }
.slot .n { position: absolute; right: 2px; bottom: 0; font-size: 11px; color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; pointer-events: none; }
.slot .k { position: absolute; left: 2px; top: 0; font-size: 9px; color: #6a5a4a; pointer-events: none; }
.slot .dur { position: absolute; left: 3px; right: 3px; bottom: 2px; height: 3px; background: #000; pointer-events: none; }
.slot .dur i { display: block; height: 100%; }
#sideBtns { position: fixed; right: calc(8px + env(safe-area-inset-right)); top: calc(224px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 6px; z-index: 5; }
#pcHelp { position: fixed; left: 8px; bottom: 8px; font-size: 11px; color: #8a7a6a; opacity: .7; z-index: 3; max-width: 24vw; }

#touch { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
#lookZone { position: absolute; right: 0; top: 0; width: 60vw; height: 100%; pointer-events: auto; touch-action: none; }
#joyZone { position: absolute; left: 0; bottom: 0; width: 45vw; height: 60vh; pointer-events: auto; }
#joyBase { position: absolute; left: 30px; bottom: calc(40px + env(safe-area-inset-bottom)); width: 116px; height: 116px; border-radius: 50%; background: rgba(255,255,255,.06); border: 2px solid rgba(255,255,255,.22); }
#joyBase.active { background: rgba(255,255,255,.1); }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(200,190,170,.45); border: 2px solid rgba(255,255,255,.4); }
#btnAtk { position: absolute; right: calc(22px + env(safe-area-inset-right)); bottom: calc(var(--slot) + 30px + env(safe-area-inset-bottom)); width: 92px; height: 92px; border-radius: 50%; pointer-events: auto;
  font-size: 36px; color: #fff; background: radial-gradient(circle at 40% 35%, #b82a22, #5a0e0a); border: 3px solid #2a0606; box-shadow: 0 0 16px rgba(180,30,20,.4); font-family: inherit; }
#btnAtk.on { filter: brightness(1.3); }
.tbtn { position: absolute; pointer-events: auto; width: 54px; height: 54px; border-radius: 50%; font-family: inherit; font-size: 16px; font-weight: 600; color: #e8dcc8; background: rgba(30,24,22,.85); border: 2px solid #5a4038; }
.tbtn.on { background: #6a5a1a; border-color: #c8a040; }
#btnUse { right: calc(126px + env(safe-area-inset-right)); bottom: calc(var(--slot) + 40px + env(safe-area-inset-bottom)); width: 62px; height: 62px; font-size: 20px; background: rgba(60,50,20,.9); border-color: #a8842a; }
#btnRel { right: calc(120px + env(safe-area-inset-right)); bottom: calc(var(--slot) + 112px + env(safe-area-inset-bottom)); }
#btnRun { right: calc(50px + env(safe-area-inset-right)); bottom: calc(var(--slot) + 132px + env(safe-area-inset-bottom)); font-size: 12px; }
#btnFl { right: calc(186px + env(safe-area-inset-right)); bottom: calc(var(--slot) + 70px + env(safe-area-inset-bottom)); }
body.touch #pcHelp { display: none; }
body.touch canvas#game { cursor: default; }

#chatBar { position: fixed; left: 50%; transform: translateX(-50%); top: 30%; width: min(500px, 94vw); display: flex; gap: 6px; z-index: 20; }
#chatBar input { flex: 1; font: inherit; font-size: 16px; padding: 8px 10px; border: 2px solid #4a3a34; border-radius: 6px; background: #0e0a09; color: #e8dcc8; outline: none; }
#toast { position: fixed; top: 14%; left: 50%; transform: translateX(-50%); z-index: 30; pointer-events: none; display: flex; flex-direction: column; align-items: center; }
#toast div { background: rgba(14,10,9,.9); border: 1px solid #4a3a34; padding: 6px 14px; border-radius: 6px; margin-bottom: 4px; text-align: center; font-size: 15px; animation: tin .2s; }
#toast div.bad { border-color: #a82a20; color: #ff8a7a; }
#toast div.good { border-color: #6a8a3a; color: #c8e8a0; }
@keyframes tin { from { transform: translateY(-6px); opacity: 0; } }

/* modal */
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 8px; }
.mbox { width: min(620px, 98vw); max-height: 92vh; display: flex; flex-direction: column; padding: 8px 10px 10px; background: rgba(16,12,11,.97); }
.mhead { display: flex; justify-content: space-between; align-items: center; font-size: 19px; font-weight: 600; color: #e8c8a8; margin-bottom: 6px; }
#mBody { overflow-y: auto; touch-action: pan-y; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 4px; }
.grid .slot { width: 100%; height: auto; aspect-ratio: 1; }
.secT { font-size: 13px; margin: 8px 0 4px; color: #9a8a7a; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.info { min-height: 60px; background: #0e0a09; border: 1px solid #3a2e2a; border-radius: 5px; padding: 6px 8px; margin-top: 6px; font-size: 13px; color: #b8a898; }
.info b { font-size: 15px; color: #e8dcc8; }
.btnRow { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.btnRow .btn { flex: 1; min-width: 80px; }
.eqRow { display: flex; gap: 8px; align-items: flex-start; }

.eqSlots { display: flex; gap: 4px; }
.eqSlots .slot { width: 48px; height: 48px; }
.eqSlots label { display: block; font-size: 10px; text-align: center; color: #7a6a5a; }
.skills { flex: 1; font-size: 12px; }
.skill { display: flex; align-items: center; gap: 5px; margin: 2px 0; }
.skill span:first-child { width: 72px; }
.skill .sb { flex: 1; height: 6px; background: #1a1412; border-radius: 2px; overflow: hidden; }
.skill .sb i { display: block; height: 100%; background: #a8842a; }
.recipe { display: flex; align-items: center; gap: 8px; padding: 6px; border-bottom: 1px dashed #3a2e2a; }
.recipe img { width: 36px; height: 36px; image-rendering: pixelated; }
.recipe .d { flex: 1; font-size: 13px; }
.recipe .need { font-size: 12px; } .recipe .ok { color: #8ac860; } .recipe .no { color: #c86050; }
#bigmap { width: 100%; image-rendering: pixelated; border: 1px solid #3a2e2a; border-radius: 4px; background: #000; touch-action: none; }

#overlay { position: fixed; inset: 0; z-index: 35; background: radial-gradient(ellipse, rgba(60,0,0,.55), rgba(0,0,0,.92)); display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px; }
.ovBox h2 { font-family: 'Creepster', 'Pixelify Sans', cursive; font-weight: 400; font-size: 52px; color: #b81e1a; margin: 0 0 8px; letter-spacing: 2px; }
.ovBox p { font-size: 16px; color: #c8b8a8; max-width: 420px; margin: 0 auto 14px; line-height: 1.4; }
.ovBox .btn { width: auto; min-width: 180px; }
#conn { position: fixed; top: 40%; left: 0; right: 0; display: flex; justify-content: center; z-index: 45; }
#conn .panel { padding: 12px 18px; }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .8s; z-index: 38; }
#fade.on { opacity: 1; }

@media (max-width: 640px) {
  .creator { flex-direction: column; align-items: center; }
  .card h1 { font-size: 40px; }
  #charOpts { max-height: 34vh; }
}
#btnMusic.off { opacity: .4; }
@media (max-height: 520px) {
  .card.wide { width: min(860px, 100%); padding: 10px 12px; }
  .card.wide h1, .card.wide .sub { display: none; }
  .creator { flex-direction: row !important; align-items: flex-start; }
  #prevHold canvas { width: 120px; height: 170px; }
  #charOpts { max-height: calc(100vh - 150px); }
  .tabs span { padding: 4px 8px; font-size: 13px; }
  #bars { width: 150px; padding: 4px 6px; }
  .bar { height: 12px; margin: 1px 0; }
  #topLeft2 { top: calc(96px + env(safe-area-inset-top)); }
  #minimap { width: 96px; height: 96px; top: calc(84px + env(safe-area-inset-top)); }
  #sideBtns { flex-direction: row; top: calc(8px + env(safe-area-inset-top)); right: calc(150px + env(safe-area-inset-right)); }
  .btn.round { width: 40px; height: 40px; font-size: 17px; }
  #chatLog { bottom: auto; top: calc(178px + env(safe-area-inset-top)); max-width: 34vw; font-size: 11px; }
  #btnRun { bottom: calc(var(--slot) + 120px + env(safe-area-inset-bottom)); }
}

#wxTxt { font-size: 12px; color: #a8b8c8; }
#tempRow { font-size: 11px; margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; color: #d8c8b8; }
.paper { background: #e8e0c8; color: #2a2018; font-family: "Segoe Print", "Bradley Hand", cursive, serif; font-size: 16px; line-height: 1.5; padding: 16px 18px; border-radius: 4px; box-shadow: inset 0 0 30px rgba(120,90,40,.35); transform: rotate(-0.6deg); margin: 6px 4px 12px; }
.paper.talk { font-family: inherit; background: #1e1814; color: #e8dcc8; transform: none; box-shadow: none; border: 1px solid #4a3a30; }

/* yeni: eğilme, görevler, özel renk */
#btnCrouch { right: calc(186px + env(safe-area-inset-right)); bottom: calc(var(--slot) + 136px + env(safe-area-inset-bottom)); font-size: 12px; }
@media (max-height: 520px) { #btnCrouch { bottom: calc(var(--slot) + 124px + env(safe-area-inset-bottom)); } }
#questHud { position: fixed; top: calc(224px + env(safe-area-inset-top)); right: calc(62px + env(safe-area-inset-right)); z-index: 5; max-width: 230px; font-size: 12px; cursor: pointer; }
#questHud div { margin-top: 2px; color: #d8c8b0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#questHud div span { color: #e8c060; }
#questHud div.ok { color: #9ae07a; }

@media (max-height: 520px) { #questHud { right: calc(112px + env(safe-area-inset-right)); top: calc(84px + env(safe-area-inset-top)); max-width: 170px; font-size: 11px; padding: 3px 6px; } #sideBtns { right: calc(186px + env(safe-area-inset-right)) !important; } }
.qbox { background: #1a1412; border: 1px solid #4a3a30; border-radius: 6px; padding: 8px 10px; margin: 8px 0; font-size: 14px; line-height: 1.35; }
.qbox.ready { border-color: #6a9a3a; background: #182014; }
.qbox .qt { font-weight: 600; color: #e8c060; margin-bottom: 4px; }
.qbox .qp { color: #c8b8a0; font-weight: 400; font-size: 12px; margin-left: 6px; }
.qbox .qs { font-size: 12px; color: #a89a8a; margin-top: 3px; }
.qbox .btn { margin-top: 6px; }
.rws { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; align-items: center; }
.rws .lbl { font-size: 12px; color: #9a8a7a; }
.rw { display: inline-flex; align-items: center; gap: 3px; background: #0e0a09; border: 1px solid #3a2e2a; border-radius: 4px; padding: 1px 6px 1px 2px; font-size: 12px; }
.rw img { width: 22px; height: 22px; }
.optRow .sw.custom { position: relative; overflow: hidden; }
.optRow .sw.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }

/* ---------- Oyun modu seçimi ---------- */
.modes { display: grid; gap: 9px; margin: 10px 0 8px; }
.modeCard {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; cursor: pointer; font-family: inherit;
  background: linear-gradient(180deg, #1c1614, #120e0d);
  border: 1px solid #3a2a26; border-radius: 10px; padding: 11px 14px;
  color: #e8dcd0; transition: border-color .15s, background .15s, transform .15s;
}
.modeCard:hover, .modeCard:focus-visible {
  border-color: #b83a32; background: linear-gradient(180deg, #2a1a18, #1a1210);
  transform: translateY(-1px); outline: none;
}
.modeCard .mi { font-size: 20px; line-height: 1.1; }
.modeCard b { font-size: 15px; color: #f0c8b0; letter-spacing: .3px; }
.modeCard small { font-size: 11px; opacity: .72; line-height: 1.3; }

/* ---- lobi (çevrimiçi co-op) ---- */
.lobby { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.lobby .btn.big { margin-top: 0; }
.joinRow { display: flex; gap: 8px; }
.joinRow input { flex: 1; text-transform: uppercase; letter-spacing: 6px; text-align: center; font-size: 20px; }
.joinRow .btn.big { width: auto; flex-shrink: 0; }
.card label.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #b8a898; cursor: pointer; margin: 2px 0; }
.card label.chk input { width: 18px; height: 18px; accent-color: #a81e1a; }
#lobbyBack { margin-top: 12px; }
.roomCode { font-size: 13px; color: #e8c890; margin-bottom: 3px; letter-spacing: 1px; user-select: text; -webkit-user-select: text; }
.roomCode b { color: #ffe0a0; letter-spacing: 3px; font-size: 15px; }
#conn { inset: 0; top: 0; align-items: center; background: rgba(0,0,0,.6); }
#conn .panel { padding: 18px 22px; text-align: center; max-width: 360px; }
#conn p { margin: 0 0 6px; }
