/* Vaeloria: twilight blue-violet interface over a natural world. */
:root {
  --bg: #0d0b1f;
  --panel: rgba(22, 18, 52, 0.9);
  --panel2: rgba(34, 28, 78, 0.92);
  --line: rgba(167, 139, 250, 0.22);
  --text: #ece9ff;
  --muted: #a9a3d9;
  --violet: #8b5cf6;
  --violet2: #a78bfa;
  --blue: #3b82f6;
  --blue2: #60a5fa;
  --good: #6ee7b7;
  --bad: #ff6b8a;
  --warn: #fbbf24;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
body { user-select: none; -webkit-user-select: none; touch-action: none; }
.hidden { display: none !important; }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* buttons */
.btn { appearance: none; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); color: var(--text); font: inherit; font-weight: 700; border-radius: 12px; height: 44px; padding: 0 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; transition: background 0.15s, transform 0.08s; }
.btn:hover { background: rgba(167, 139, 250, 0.16); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(135deg, var(--violet), var(--blue)); border-color: transparent; box-shadow: 0 6px 24px rgba(99, 102, 241, 0.35); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { height: 52px; font-size: 17px; width: 100%; }
.btn.small { height: 36px; padding: 0 12px; font-size: 14px; }
.btn.ghost { background: transparent; }
.btn.on { background: rgba(110, 231, 183, 0.18); border-color: rgba(110, 231, 183, 0.5); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

/* menu screens */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); background: radial-gradient(900px 600px at 50% 0%, rgba(139, 92, 246, 0.35), transparent 60%), radial-gradient(700px 500px at 80% 100%, rgba(59, 130, 246, 0.25), transparent 60%), rgba(9, 7, 24, 0.82); overflow: auto; z-index: 10; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 22px; width: 100%; max-width: 420px; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5); display: flex; flex-direction: column; gap: 12px; backdrop-filter: blur(8px); }
.menu-card { text-align: center; }
.star { width: 64px; height: 64px; margin: 0 auto -4px; background: conic-gradient(from 0deg, #c4b5fd, #60a5fa, #a78bfa, #c4b5fd); clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); filter: drop-shadow(0 0 18px rgba(167, 139, 250, 0.9)); animation: twinkle 3s ease-in-out infinite; }
@keyframes twinkle { 50% { transform: scale(1.08) rotate(8deg); filter: drop-shadow(0 0 28px rgba(96, 165, 250, 0.9)); } }
h1 { margin: 0; font-size: 34px; letter-spacing: 1px; background: linear-gradient(90deg, #c4b5fd, #93c5fd); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { margin: 0; font-size: 20px; }
.sub { margin: 0 0 4px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; text-align: left; font-size: 13px; color: var(--muted); }
input { font: inherit; color: var(--text); background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 12px; height: 44px; padding: 0 12px; outline: none; user-select: text; -webkit-user-select: text; }
input:focus { border-color: var(--violet2); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.code-row input { text-transform: uppercase; letter-spacing: 3px; text-align: center; font-weight: 800; }
.links { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.err { color: var(--bad); margin: 0; font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.room { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); cursor: pointer; }
.room:hover { background: rgba(167, 139, 250, 0.14); }
.room b { letter-spacing: 2px; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.code { letter-spacing: 3px; color: var(--violet2); }
.seat { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid transparent; }
.seat.me { border-color: var(--line); background: rgba(139, 92, 246, 0.12); }
.seat .dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.7); flex: none; cursor: pointer; }
.seat .nm { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .nm small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.seat .tm { height: 30px; padding: 0 10px; border-radius: 10px; font-size: 12px; }
.seat .rd { font-size: 12px; font-weight: 800; color: var(--muted); }
.seat .rd.ok { color: var(--good); }
.seat.off { opacity: 0.5; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
#top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 6px; padding: calc(6px + var(--safe-t)) calc(8px + var(--safe-r)) 6px calc(8px + var(--safe-l)); background: linear-gradient(180deg, rgba(13, 11, 31, 0.92), rgba(13, 11, 31, 0.6)); border-bottom: 1px solid var(--line); }
.res { display: flex; gap: 4px; flex: 1; min-width: 0; overflow: hidden; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 9px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); font-weight: 800; font-size: 14px; white-space: nowrap; color: var(--text); }
.chip.low b { color: var(--bad); }
.chip.flash { animation: flash 0.6s; }
@keyframes flash { 30% { background: rgba(167, 139, 250, 0.45); } }
.season { cursor: pointer; font: inherit; font-weight: 800; font-size: 13px; }
.season .bar { display: block; width: 34px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.season .bar u { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--violet2), var(--blue2)); }
.table { color: var(--good); font-size: 12px; }
.table.hungry { color: var(--bad); }
.iconbtn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); color: var(--text); display: grid; place-items: center; cursor: pointer; flex: none; }
.iconbtn svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; }

#mini { position: absolute; top: calc(52px + var(--safe-t)); left: calc(8px + var(--safe-l)); width: 150px; height: 150px; border-radius: 12px; border: 2px solid var(--line); background: #000; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); image-rendering: pixelated; }

#groups { position: absolute; right: calc(8px + var(--safe-r)); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; }
.grp { width: 48px; height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 900; font-size: 17px; position: relative; cursor: pointer; display: grid; place-items: center; touch-action: none; }
.grp small { position: absolute; bottom: 2px; right: 5px; font-size: 10px; color: var(--muted); font-weight: 700; }
.grp.empty { opacity: 0.45; }
.grp.sel { border-color: var(--violet2); box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.4); }
.grp.saved { animation: flash 0.6s; }

#quick { position: absolute; left: calc(8px + var(--safe-l)); bottom: calc(8px + var(--safe-b)); display: flex; gap: 6px; }
.qbtn { min-width: 64px; height: 56px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-size: 11px; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; position: relative; padding: 0 8px; }
.qbtn b { position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--violet); font-size: 12px; display: grid; place-items: center; padding: 0 5px; }
.qbtn b.zero { background: #3a3560; color: var(--muted); }
.qbtn.accent { background: linear-gradient(135deg, rgba(139, 92, 246, 0.9), rgba(59, 130, 246, 0.9)); border-color: transparent; }
.qbtn:active, .grp:active { transform: scale(0.95); }

#panel { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(72px + var(--safe-b)); width: min(560px, calc(100% - 16px)); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45); }
.p-head { display: flex; align-items: center; gap: 10px; }
.p-head .ttl { flex: 1; font-weight: 800; font-size: 16px; }
.p-head .ttl small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.p-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.p-row .lbl { color: var(--muted); font-size: 13px; min-width: 76px; }
.meter { flex: 1; min-width: 80px; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.meter u { display: block; height: 100%; background: linear-gradient(90deg, var(--violet2), var(--blue2)); }
.step { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; padding: 0; }
.wk { font-weight: 900; font-size: 16px; min-width: 44px; text-align: center; }
.jobs { display: flex; flex-wrap: wrap; gap: 4px; }
.jobs span { font-size: 12px; padding: 3px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.07); color: var(--muted); }
.xbtn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; }

#buildmenu { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(72px + var(--safe-b)); width: min(560px, calc(100% - 16px)); background: var(--panel2); border: 1px solid var(--line); border-radius: 16px; padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45); }
.bcard { display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.bcard:hover { background: rgba(167, 139, 250, 0.16); }
.bcard canvas { width: 46px; height: 46px; flex: none; }
.bcard b { display: block; font-size: 14px; }
.bcard small { display: block; color: var(--muted); font-size: 11px; line-height: 1.25; }
.bcard .cost { color: var(--warn); font-weight: 800; font-size: 12px; }
.bcard.no { opacity: 0.5; }
.bcard.no .cost { color: var(--bad); }

#placebar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(72px + var(--safe-b)); display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; max-width: calc(100% - 16px); }
#placebar span { font-size: 13px; color: var(--muted); }
#placebar span.bad { color: var(--bad); }

#toasts { position: absolute; top: calc(52px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; width: min(420px, calc(100% - 180px)); }
.toast { padding: 7px 14px; border-radius: 12px; background: rgba(22, 18, 52, 0.94); border: 1px solid var(--line); font-weight: 700; font-size: 13px; animation: toast 3s forwards; text-align: center; }
.toast.bad { border-color: rgba(255, 107, 138, 0.6); color: #ffd0da; }
.toast.good { border-color: rgba(110, 231, 183, 0.5); }
@keyframes toast { 0% { opacity: 0; transform: translateY(-6px); } 8%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
#netbad { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); padding: 12px 18px; border-radius: 14px; background: rgba(60, 10, 30, 0.9); border: 1px solid var(--bad); font-weight: 800; }

.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(6, 4, 18, 0.66); z-index: 20; }
.modal .card { max-width: 460px; }
.modal .big-title { font-size: 30px; text-align: center; margin: 0; }
.help { font-size: 14px; line-height: 1.5; color: var(--text); max-height: 55vh; overflow: auto; }
.help b { color: var(--violet2); }

/* icons */
.ic { width: 18px; height: 18px; display: inline-block; background: center / contain no-repeat; flex: none; }
.ic-wood { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='9' width='18' height='6' rx='3' fill='%23a0693a'/%3E%3Ccircle cx='19' cy='12' r='2.6' fill='%23e8c08a'/%3E%3Crect x='5' y='3' width='14' height='5' rx='2.5' fill='%238a5a30'/%3E%3Crect x='5' y='16' width='14' height='5' rx='2.5' fill='%238a5a30'/%3E%3C/svg%3E"); }
.ic-fish { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cellipse cx='10' cy='12' rx='8' ry='5' fill='%2393c5fd'/%3E%3Cpath d='M17 12l5-4v8z' fill='%2360a5fa'/%3E%3Ccircle cx='6' cy='11' r='1.2' fill='%231e293b'/%3E%3C/svg%3E"); }
.ic-wheat { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 22V6' stroke='%23d9b44a' stroke-width='2'/%3E%3Cg fill='%23f0d27a'%3E%3Cellipse cx='9' cy='8' rx='2' ry='3.4' transform='rotate(-25 9 8)'/%3E%3Cellipse cx='15' cy='8' rx='2' ry='3.4' transform='rotate(25 15 8)'/%3E%3Cellipse cx='9' cy='13' rx='2' ry='3.4' transform='rotate(-25 9 13)'/%3E%3Cellipse cx='15' cy='13' rx='2' ry='3.4' transform='rotate(25 15 13)'/%3E%3Cellipse cx='12' cy='4' rx='2' ry='3'/%3E%3C/g%3E%3C/svg%3E"); }
.ic-berry { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3c2 2 5 2 6 1' stroke='%2322c55e' stroke-width='2' fill='none'/%3E%3Ccircle cx='8' cy='14' r='5' fill='%237c3aed'/%3E%3Ccircle cx='16' cy='13' r='5' fill='%238b5cf6'/%3E%3Ccircle cx='12' cy='19' r='4' fill='%236d28d9'/%3E%3Ccircle cx='14.5' cy='11.5' r='1.3' fill='%23ddd6fe'/%3E%3C/svg%3E"); }
.ic-pop { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='7' r='4' fill='%23f0c8a0'/%3E%3Cpath d='M4 22c0-6 4-9 8-9s8 3 8 9z' fill='%23a78bfa'/%3E%3C/svg%3E"); }
.ic-all { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='7' cy='8' r='3' fill='%23f0c8a0'/%3E%3Ccircle cx='17' cy='8' r='3' fill='%23f0c8a0'/%3E%3Cpath d='M1 20c0-5 3-7 6-7s6 2 6 7zM11 20c0-5 3-7 6-7s6 2 6 7z' fill='%2360a5fa'/%3E%3C/svg%3E"); }
.ic-hall { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2 11L12 3l10 8z' fill='%237c6fbf'/%3E%3Crect x='4' y='11' width='16' height='10' fill='%23d9c7a4'/%3E%3Crect x='10' y='14' width='4' height='7' fill='%233a2618'/%3E%3C/svg%3E"); }
.ic-build { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M14 4l6 6-3 3-6-6z' fill='%23e5e7eb'/%3E%3Cpath d='M12 9l3 3-9 9-3-3z' fill='%23d9a066'/%3E%3C/svg%3E"); }
.season .ic { width: 16px; height: 16px; border-radius: 50%; }
.s0 .ic { background: radial-gradient(circle, #ffd6ec 30%, #86efac 32%); }
.s1 .ic { background: radial-gradient(circle, #fde047 45%, #f59e0b 47%); }
.s2 .ic { background: radial-gradient(circle, #fb923c 45%, #b45309 47%); }
.s3 .ic { background: radial-gradient(circle, #f8fafc 45%, #93c5fd 47%); }

/* phones */
@media (max-width: 700px) {
  .chip { height: 28px; padding: 0 6px; font-size: 12px; gap: 3px; }
  .ic { width: 15px; height: 15px; }
  .season span { display: none; }
  #mini { width: 104px; height: 104px; top: calc(46px + var(--safe-t)); }
  .grp { width: 44px; height: 44px; }
  .qbtn { min-width: 58px; height: 52px; font-size: 10px; }
  #panel, #buildmenu, #placebar { bottom: calc(68px + var(--safe-b)); }
  #buildmenu { grid-template-columns: 1fr 1fr; }
  .bcard small.d { display: none; }
  #toasts { width: calc(100% - 140px); top: calc(46px + var(--safe-t)); left: calc(50% + 50px); }
  #groups { top: auto; bottom: calc(72px + var(--safe-b)); transform: none; }
  #panel { width: calc(100% - 70px); left: calc(8px + var(--safe-l)); transform: none; }
}
