@font-face { font-family: 'Fraunces'; src: url('fonts/Fraunces.ttf') format('truetype'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fonts/Inter-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #070b1f; color: #e9ecf7; font: 600 14px/1.35 Inter, system-ui, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; touch-action: manipulation; }
#app { position: fixed; inset: 0; display: flex; flex-direction: row; user-select: none; -webkit-user-select: none; }
#stage { position: relative; flex: 1; min-width: 0; overflow: hidden; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }
#panel { width: 340px; display: flex; flex-direction: column; background: #10152c; border-left: 1px solid #222a4a; min-height: 0; }
#hud { position: absolute; top: 8px; left: 0; right: 0; text-align: center; pointer-events: none; text-shadow: 0 2px 6px #000; }
#glow { font: 700 30px/1.1 Fraunces, Georgia, serif; color: #ffe2a0; }
#rate { font-size: 12px; color: #c6cde6; }
#where { position: absolute; left: 10px; bottom: 8px; right: 10px; display: flex; align-items: center; gap: 8px; pointer-events: none; font-size: 12px; color: #c6cde6; text-shadow: 0 1px 4px #000; }
#where-name { font-family: Fraunces, Georgia, serif; font-size: 14px; color: #fff; white-space: nowrap; }
#goal { flex: 1; height: 6px; background: rgba(0,0,0,.45); border-radius: 3px; overflow: hidden; max-width: 220px; }
#goal-fill, #lamp-fill { height: 100%; width: 0; background: linear-gradient(90deg, #ff9a3a, #ffe08a); border-radius: 3px; transition: width .3s; }
#goal-text { white-space: nowrap; }
#bell { position: absolute; right: 10px; top: 10px; }
.pill { background: #ffcf73; color: #2a1c05; padding: 8px 14px; border-radius: 20px; box-shadow: 0 2px 10px rgba(0,0,0,.4); }
.pill.cool { background: #3a4266; color: #aab3d6; }
#hint { position: absolute; left: 50%; bottom: 25%; transform: translateX(-50%); background: rgba(10,14,35,.75); padding: 6px 12px; border-radius: 14px; font-size: 13px; pointer-events: none; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translate(-50%, -5px); } }
#toasts { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); width: min(92%, 380px); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: rgba(20,26,55,.94); border: 1px solid #3a4677; border-radius: 10px; padding: 8px 12px; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.4); animation: tin .3s ease-out; }
.toast b { color: #ffd27a; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }
#tabs { display: flex; border-bottom: 1px solid #222a4a; }
#tabs button { flex: 1; padding: 11px 4px; background: none; color: #9aa3c7; position: relative; }
#tabs button.on { color: #ffe2a0; box-shadow: inset 0 -2px 0 #ffcf73; }
.badge { position: absolute; top: 6px; right: 6px; min-width: 8px; height: 8px; border-radius: 4px; background: #ff8a3d; }
.tab { display: none; flex: 1; overflow-y: auto; padding: 10px; -webkit-overflow-scrolling: touch; min-height: 0; }
.tab.on { display: block; }
.seg { display: flex; gap: 4px; margin-bottom: 8px; }
.seg button { flex: 1; padding: 6px; background: #1b2244; border-radius: 8px; color: #aab3d6; }
.seg button.on { background: #ffcf73; color: #2a1c05; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; background: #161c3a; margin-bottom: 6px; transition: background .15s; }
.row.can { background: #1f2850; }
.row.new { animation: pulse 1.2s ease-out 2; }
@keyframes pulse { 50% { box-shadow: 0 0 0 2px #ffcf73; } }
.ico { width: 30px; height: 30px; border-radius: 50%; flex: 0 0 30px; box-shadow: 0 0 12px currentColor; background: currentColor; opacity: .9; }
.row .info { flex: 1; min-width: 0; }
.row .nm { display: flex; justify-content: space-between; gap: 6px; }
.row .own { color: #ffe2a0; font-family: Fraunces, Georgia, serif; font-size: 16px; }
.row .sub2 { font-size: 11px; color: #8f98bd; }
.buy { min-width: 84px; padding: 8px 6px; border-radius: 8px; background: #ffcf73; color: #2a1c05; text-align: center; font-size: 12px; }
.buy:disabled { background: #2a3158; color: #6f789e; cursor: default; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.up { text-align: left; padding: 8px; border-radius: 10px; background: #161c3a; border: 1px solid #262e57; display: flex; flex-direction: column; gap: 3px; }
.up:disabled { opacity: .55; cursor: default; }
.up .t { color: #fff; }
.up .d { font-size: 11px; color: #a5aed1; flex: 1; }
.up .c { font-size: 12px; color: #ffd27a; }
.up.on { border-color: #ffcf73; background: #2a2a40; }
.card { background: #161c3a; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.card h3, h3.sub { margin: 0 0 4px; font: 600 16px Fraunces, Georgia, serif; color: #ffe2a0; }
h3.sub { margin: 12px 2px 6px; }
.card p { margin: 4px 0 8px; }
.card button:not(.up) { padding: 8px 12px; border-radius: 8px; background: #2a3158; margin: 2px 4px 2px 0; }
.card button.big { width: 100%; padding: 11px; background: #ffcf73; color: #2a1c05; font-size: 15px; margin-top: 4px; }
.card button.big:disabled { background: #2a3158; color: #6f789e; cursor: default; }
.card button.danger { background: #4a2030; color: #ffb3b3; }
.muted { color: #8f98bd; font-size: 12px; }
.bar { height: 8px; background: #0b0f24; border-radius: 4px; overflow: hidden; margin: 6px 0; }
.stat b { color: #ffe2a0; font-family: Fraunces, Georgia, serif; font-size: 18px; }
.dist { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 10px; background: #131833; margin-bottom: 5px; width: 100%; text-align: left; }
.dist.lit { background: #262a3a; }
.dist.view { box-shadow: inset 0 0 0 1px #ffcf73; }
.dist .st { font-size: 12px; color: #8f98bd; }
.dist.lit .st { color: #ffd27a; }
.ks { display: flex; gap: 8px; padding: 7px 10px; border-radius: 10px; background: #131833; margin-bottom: 5px; }
.ks.got { background: #2a2440; }
.ks .at { color: #ff9a3a; min-width: 34px; }
.ks:not(.got) .d { color: #6f789e; }
#modal { position: fixed; inset: 0; background: rgba(3,5,16,.72); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 5; }
#modal[hidden] { display: none; }
.box { background: #161c3a; border: 1px solid #3a4677; border-radius: 16px; padding: 18px 20px; max-width: 380px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.6); animation: tin .3s; }
.box h2 { margin: 0 0 8px; font: 700 24px Fraunces, Georgia, serif; color: #ffe2a0; }
.box p { margin: 0 0 14px; color: #d4d9ee; }
#m-btns button { padding: 10px 18px; border-radius: 10px; background: #ffcf73; color: #2a1c05; margin: 3px; font-size: 15px; }
#m-btns button.alt { background: #2a3158; color: #e9ecf7; }
[hidden] { display: none !important; }

/* phone / portrait (keep last so it wins) */
@media (max-aspect-ratio: 1/1), (max-width: 620px) {
  #app { flex-direction: column; }
  #stage { flex: 0 0 44%; }
  #panel { width: auto; flex: 1; border-left: 0; border-top: 1px solid #222a4a; }
  #bell { top: auto; bottom: 30px; padding: 6px 11px; font-size: 12px; }
  #glow { font-size: 26px; }
  #toasts { top: 56px; }
  #toasts .toast:not(:last-child) { display: none; }
  .toast { font-size: 12px; padding: 6px 10px; }
}
