* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #1b2e1d; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #2b2116; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#app { position: relative; height: 100%; max-width: 520px; margin: 0 auto; overflow: hidden; background: #2f5d34; }
.screen { position: absolute; inset: 0; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: none; }

/* Prihlásenie */
#join { display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 20%, #8fd17a, #2f5d34 70%); overflow-y: auto; padding: 16px; }
.join-card { background: #fff8e7; border-radius: 22px; padding: 22px 20px; width: 100%; max-width: 380px; box-shadow: 0 10px 30px #0006; border: 4px solid #8b5a2b; text-align: center; }
.join-card h1 { margin: 0 0 6px; font-size: 28px; color: #6b3fa0; }
.sub { margin: 0 0 14px; font-size: 14px; color: #6b5a40; }
.join-card label { display: block; text-align: left; font-weight: 600; font-size: 14px; margin: 10px 0; }
.join-card input { display: block; width: 100%; margin-top: 4px; padding: 12px; border-radius: 12px; border: 2px solid #c9a46a; font-size: 17px; background: #fff; touch-action: auto; user-select: text; -webkit-user-select: text; }
.pick-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-weight: 600; font-size: 14px; }
.pick-row span { width: 50px; text-align: left; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #c9a46a; }
.sw.on { box-shadow: 0 0 0 3px #6b3fa0; transform: scale(1.12); }
#jPreview { width: 96px; height: 96px; image-rendering: pixelated; }
.big { width: 100%; padding: 14px; border-radius: 14px; background: linear-gradient(#a978e0, #6b3fa0); color: #fff; font-size: 18px; font-weight: 700; box-shadow: 0 4px 0 #4a2a72; }
.big:disabled { opacity: .5; box-shadow: none; }
.big:active { transform: translateY(3px); box-shadow: 0 1px 0 #4a2a72; }
.hint { font-size: 12px; color: #8a7a5a; margin-bottom: 0; }

/* Hra */
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#hud { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: calc(env(safe-area-inset-top) + 8px) 8px 0; pointer-events: none; }
.hud-left, .hud-right { background: #fff8e7ee; border: 3px solid #8b5a2b; border-radius: 14px; padding: 5px 10px; font-weight: 700; font-size: 14px; pointer-events: auto; box-shadow: 0 3px 0 #0003; }
.hud-right { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; }
#hDate { font-size: 12px; color: #6b5a40; }
#hSky { cursor: pointer; }
.hbtn { background: #f0dcb0; border-radius: 10px; width: 36px; height: 34px; font-size: 18px; }
#toasts { position: absolute; top: calc(env(safe-area-inset-top) + 64px); left: 10px; right: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: #fff8e7f2; border: 2px solid #8b5a2b; border-radius: 12px; padding: 6px 11px; font-size: 13px; font-weight: 600; max-width: 100%; box-shadow: 0 3px 8px #0004; animation: tin .25s ease-out; text-align: center; }
.toast.magic { background: linear-gradient(135deg, #f3e5ff, #ffe4f5); border-color: #9b59d0; color: #4a2a72; }
.toast.gift { border-color: #e08a1e; background: #fff1d6; }
.toast.day { border-color: #3c7d3f; background: #eaffdf; }
.toast.out { opacity: 0; transition: opacity .5s; }
@keyframes tin { from { transform: translateY(-10px); opacity: 0; } }
#chatlog { position: absolute; left: 8px; bottom: 150px; max-width: 70%; display: flex; flex-direction: column; gap: 3px; pointer-events: none; }
.chatline { background: #0008; color: #fff; padding: 3px 8px; border-radius: 8px; font-size: 13px; transition: opacity 1s; }
.chatline b { color: #ffd76a; }

#bottom { position: absolute; left: 0; right: 0; bottom: 0; pointer-events: none; padding: 4px 0 env(safe-area-inset-bottom); background: #1b2e1de6; border-top: 2px solid #8b5a2b; box-shadow: 0 -4px 12px #0004; }
#selName { text-align: center; color: #fff; font-size: 12.5px; font-weight: 600; height: 18px; text-shadow: 0 1px 2px #000; }
/* Mobil: lišta na celú šírku – aspoň 6 miest (prázdne doplnia rad), viac predmetov sa posúva do strany */
#hotbar { pointer-events: auto; display: flex; gap: 6px; padding: 6px 8px; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; }
#hotbar::-webkit-scrollbar { display: none; }
.slot { position: relative; flex: 1 0 52px; max-width: 80px; aspect-ratio: 1; border-radius: 12px; background: #fff8e7; border: 3px solid #8b5a2b; display: flex; align-items: center; justify-content: center; }
.slot img { width: 72%; height: 72%; pointer-events: none; }
.slot.empty { background: #fff8e714; border: 2px dashed #fff8e740; }
.slot.empty:nth-child(n+7) { display: none; } /* mobil: rad doplnia prázdne miesta len do 6 */
.slot.on { border-color: #ffd23f; box-shadow: 0 0 0 3px #ffd23f88; transform: translateY(-3px); }
.slot .n { position: absolute; right: 2px; bottom: 0; font-size: 12px; font-weight: 800; color: #2b2116; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.slot .wbar { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 4px; background: #0002; border-radius: 2px; }
.slot .wbar i { display: block; height: 100%; background: #3aa0ff; border-radius: 2px; }
.slot .wbar.fresh { bottom: 2px; right: 22px; }
.slot .n { z-index: 1; }
.slot .k { display: none; position: absolute; left: 4px; top: 1px; font-size: 10px; font-weight: 800; color: #8b5a2b; }
#joy { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: #ffffff22; border: 3px solid #ffffff66; pointer-events: none; z-index: 3; box-shadow: 0 0 0 1px #0002; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #cfc0a0); box-shadow: 0 3px 6px #0006; }
/* Skok a plazenie: tlačidlá pre pravý palec nad lištou nástrojov, len na dotykových zariadeniach */
#moves { position: absolute; right: 10px; bottom: calc(var(--bar-h, 150px) + 12px); display: none; flex-direction: column; align-items: center; gap: 10px; z-index: 2; pointer-events: none; }
#game.touch #moves { display: flex; }
@media (pointer: coarse) { #moves { display: flex; } }
.mvbtn { pointer-events: auto; border-radius: 50%; background: #fff8e7cc; border: 3px solid #8b5a2b; box-shadow: 0 3px 0 #0004; color: #5b3a1a; font-weight: 800; touch-action: none; }
#bJump { width: 64px; height: 64px; font-size: 30px; }
#bCrawl { width: 46px; height: 46px; font-size: 22px; }
#bCrawl.on { background: #ffe082; border-color: #e0a020; box-shadow: 0 0 0 4px #ffe08266, 0 3px 0 #0004; }
.mvbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0004; }
#emotes { display: flex; justify-content: center; gap: 10px; padding: 2px 8px 8px; }
#emotes button { pointer-events: auto; width: 42px; height: 42px; border-radius: 50%; background: #fff8e7cc; font-size: 20px; box-shadow: 0 2px 0 #0004; }

/* Modálne okná */
#modal { position: absolute; inset: 0; background: #0008; display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.modal-card { background: #fff8e7; width: 100%; max-height: 82%; border-radius: 22px 22px 0 0; border: 4px solid #8b5a2b; border-bottom: none; display: flex; flex-direction: column; animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 2px dashed #d9bf8c; }
.modal-head h2 { margin: 0; font-size: 20px; }
#mClose { background: #f0dcb0; border-radius: 10px; width: 38px; height: 38px; font-size: 18px; }
#mBody { overflow-y: auto; padding: 10px 14px calc(env(safe-area-inset-bottom) + 16px); touch-action: pan-y; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; padding: 9px; border-radius: 10px; background: #f0dcb0; font-weight: 700; }
.tabs button.on { background: #8b5a2b; color: #fff; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: #fff; margin-bottom: 6px; border: 2px solid #f0dcb0; }
.row img { width: 40px; height: 40px; flex: 0 0 auto; }
.row .info { flex: 1; min-width: 0; }
.row .info b { display: block; font-size: 14.5px; }
.row .info small { display: block; color: #7a6a4a; font-size: 12px; }
.row .btns { display: flex; gap: 4px; }
.btn { padding: 8px 10px; border-radius: 10px; background: #6b3fa0; color: #fff; font-weight: 700; font-size: 13px; white-space: nowrap; }
.btn.alt { background: #3c7d3f; }
.btn.gray { background: #b9a888; }
.btn:disabled { opacity: .45; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 8px; font-size: 11px; background: #eee; margin-right: 3px; }
.badge.now { background: #b8f0a0; }
.dlg { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.dlg canvas { flex: 0 0 auto; }
.bubble { background: #fff; border: 2px solid #d9bf8c; border-radius: 14px; padding: 10px 12px; font-size: 14.5px; line-height: 1.4; }
.cauldron-slots { display: flex; justify-content: center; gap: 10px; margin: 6px 0 12px; }
.cslot { width: 64px; height: 64px; border-radius: 50%; border: 3px dashed #8b5a2b; background: #3a2a4a; display: flex; align-items: center; justify-content: center; }
.cslot img { width: 48px; height: 48px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
.gcell { position: relative; background: #fff; border: 2px solid #f0dcb0; border-radius: 12px; padding: 4px; text-align: center; }
.gcell img { width: 44px; height: 44px; }
.gcell .n { position: absolute; right: 5px; top: 2px; font-size: 12px; font-weight: 800; }
.card { background: #fff; border: 2px solid #f0dcb0; border-radius: 14px; padding: 10px; margin-bottom: 8px; display: flex; gap: 10px; }
.card img { width: 56px; height: 56px; flex: 0 0 auto; }
.card .latin { font-style: italic; color: #7a6a4a; font-size: 12.5px; }
.card p { margin: 5px 0 0; font-size: 13px; line-height: 1.35; }
.card.locked { opacity: .55; }
.card.magic { border-color: #c9a0f0; background: linear-gradient(135deg, #fff, #f7eeff); }
.wish { display: block; width: 100%; text-align: left; padding: 12px; margin-bottom: 8px; border-radius: 14px; background: linear-gradient(135deg, #f3e5ff, #ffe4f5); border: 2px solid #9b59d0; font-size: 15px; }
.wish b { display: block; font-size: 16px; color: #4a2a72; }
.help p { font-size: 14px; line-height: 1.45; margin: 6px 0; }
#chatbox { position: absolute; left: 8px; right: 8px; bottom: 156px; display: flex; gap: 6px; z-index: 5; }
#chatbox input { flex: 1; padding: 11px; border-radius: 12px; border: 2px solid #8b5a2b; font-size: 16px; touch-action: auto; user-select: text; -webkit-user-select: text; }
#chatbox button { width: 48px; border-radius: 12px; background: #6b3fa0; color: #fff; font-size: 18px; }
#conn { position: absolute; top: 40%; left: 50%; transform: translateX(-50%); background: #000b; color: #fff; padding: 12px 18px; border-radius: 14px; z-index: 20; font-weight: 700; }
/* Trend ceny: ikonka z 3 šípok nad sebou */
.tr { display: inline-block; vertical-align: middle; line-height: 0; margin: 0 2px; }
/* 3D: WebGL plátno pod prekrytím a tlačidlá otáčania pohľadu v horných rohoch */
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#cv.overlay { background: transparent; }
.rotbtn { position: absolute; top: calc(env(safe-area-inset-top) + 74px); width: 46px; height: 46px; border-radius: 50%; background: #fff8e7e6; border: 3px solid #8b5a2b; font-size: 24px; font-weight: 800; color: #5b3a1a; box-shadow: 0 3px 0 #0003; z-index: 2; }
#rotL { left: 8px; } #rotR { right: 8px; }
.rotbtn:active { transform: translateY(2px); }
/* Spánok: stmavenie obrazovky, svet za ním pretáča noc */
#sleep { position: absolute; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle, #0b1030aa, #050818e6); }
#sleep .sl-card { text-align: center; color: #fff; padding: 20px; max-width: 80%; font-weight: 700; font-size: 17px; }
#sleep .sl-z { font-size: 54px; animation: slz 2s ease-in-out infinite; }
#sleep button { margin-top: 14px; }
@keyframes slz { 50% { transform: translateY(-10px); opacity: .6; } }

/* Počítač (a tablet na šírku): hra na celú obrazovku; koľko sveta je vidno, určuje uhlopriečka (D.VIEW_DIAG) */
@media (min-width: 820px) and (min-aspect-ratio: 1/1) {
  #app { max-width: none; }
  /* Počítač: žiadny pás cez celú obrazovku – panel v strede s pevnou šírkou na 9 miest (klávesy 1–9) */
  #bottom { left: 50%; right: auto; bottom: 12px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); display: grid; grid-template-columns: auto auto; align-items: center; column-gap: 14px; padding: 6px 14px 10px; border: 3px solid #8b5a2b; border-radius: 18px; box-shadow: 0 4px 14px #0006; }
  #selName { grid-column: 1 / -1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #hotbar { padding: 4px 0 0; width: calc(9 * 58px + 8 * 6px); max-width: 100%; }
  .slot { flex: 0 0 58px; }
  .slot.empty:nth-child(n) { display: flex; }
  #emotes { padding: 4px 0 0; gap: 8px; }
  #chatbox { left: 50%; right: auto; width: min(560px, calc(100% - 16px)); transform: translateX(-50%); }
  #modal { align-items: center; }
  .modal-card { max-width: 620px; max-height: 86%; border-radius: 22px; border-bottom: 4px solid #8b5a2b; }
  #mBody { padding-bottom: 16px; }
}
@media (hover: hover) and (pointer: fine) { .slot .k { display: block; } }
