/* Grown - look and feel. Dark space, white and yellow. Colors are variables so a new theme is easy. */
:root {
  --bg: #08080b;
  --panel: rgba(22,22,26,0.92);
  --panel2: #22222a;
  --line: #3b3b46;
  --text: #f1f1ec;
  --dim: #a0a0aa;
  --accent: #8a7dff;
  --good: #8fd16a;
  --bad: #ff6a3d;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-user-select: none; user-select: none; touch-action: none; }
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
.ico { color: var(--accent); display: inline-block; min-width: 1em; text-align: center; }

/* ---- HUD ---- */
#hud { position: fixed; inset: 0; pointer-events: none; display: flex; justify-content: space-between; padding: 10px 12px; gap: 12px; }
#hud button { pointer-events: auto; }
.hud-left, .hud-right { width: 260px; }
.hud-center { flex: 1; max-width: 520px; text-align: center; }
.hud-right { text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; line-height: 1.5; text-shadow: 0 1px 3px #000; }
.level { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; text-shadow: 0 2px 6px #000; }
.lv-label { font-size: 11px; letter-spacing: 0.2em; color: var(--dim); }
.lv-num { font-size: 34px; font-weight: 800; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; display: inline-block; transform-origin: left bottom; }
.lv-num.pop { animation: lvpop 0.22s ease-out; }
@keyframes lvpop { 0% { transform: scale(1.45); color: #fff; } 100% { transform: scale(1); } }
.lv-gain { font-size: 18px; font-weight: 700; color: #fff; opacity: 0; transition: opacity 0.15s; font-variant-numeric: tabular-nums; }
.bar { position: relative; height: 16px; background: rgba(0,0,0,0.6); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 5px; }
.bar .fill { position: absolute; inset: 0 auto 0 0; width: 0%; background: var(--text); transition: width 0.1s linear; border-radius: 8px; }
.bar.hp .fill { background: linear-gradient(#e9e9e2, #9c9c94); }
.bar.xp .fill { background: linear-gradient(#cfc8ff, #6f5ff0); }
.bar.xp { height: 12px; }
.bar.xp span { font-size: 10px; line-height: 10px; }
.bar.frenzy { height: 12px; }
.bar.frenzy span { font-size: 10px; line-height: 10px; letter-spacing: 0.1em; }
.bar.frenzy .fill { background: linear-gradient(90deg, #ff6a3d, #9d8bff); }
.bar.frenzy.on { border-color: #9d8bff; box-shadow: 0 0 14px rgba(255,150,40,0.8); }
.bar.frenzy.on .fill { background: linear-gradient(90deg, #b3a8ff, #fff); }
.bar.tier { height: 18px; }
.bar.tier .fill { background: linear-gradient(#cfc8ff, #6f5ff0); }
.bar.tier.boss .fill { background: linear-gradient(#ff8a5c, #d93a1c); }
.bar span { position: relative; display: block; text-align: center; font-size: 12px; line-height: 14px; color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000, 1px 1px 1px #000, -1px -1px 1px #000; }
.bar.tier span { line-height: 16px; }
.tier-name { font-size: 17px; font-weight: 600; letter-spacing: 0.06em; margin-bottom: 4px; text-shadow: 0 2px 6px #000; }
.tier-name small { color: var(--dim); font-weight: 400; margin-left: 6px; }
.attacks { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.attacks .a { background: rgba(0,0,0,0.6); border: 1px solid var(--line); border-radius: 10px; padding: 2px 8px; font-size: 12px; }
.attacks .a.fused { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 8px rgba(138,125,255,0.45); }
.attacks .a.ready { border-color: #fff; }
.attacks .a.empty { color: #666; border-style: dashed; }
#btn-pause { margin-top: 6px; width: 40px; height: 32px; background: rgba(0,0,0,0.6); border: 1px solid var(--line); border-radius: 6px; }
.banner { position: absolute; top: 19%; left: 0; right: 0; text-align: center; font-size: 24px; font-weight: 700; letter-spacing: 0.05em; text-shadow: 0 2px 10px #000, 0 0 18px rgba(138,125,255,0.5); color: var(--accent); padding: 0 12px; }
.dash { position: absolute; right: 18px; bottom: 22px; width: 76px; height: 76px; border-radius: 50%; background: rgba(0,0,0,0.5); border: 2px solid var(--accent); color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: 0.08em; transition: opacity 0.15s; }

/* ---- Overlay screens ---- */
.overlay { position: fixed; inset: 0; background: rgba(8,8,11,0.9); overflow-y: auto; display: flex; justify-content: center; align-items: flex-start; padding: 24px 14px 60px; touch-action: pan-y; }
.overlay.clear { background: rgba(8,8,11,0.66); }
.overlay.menu { background: rgba(8,8,11,0.5); }
.screen { width: 100%; max-width: 920px; }
h1 { font-size: 64px; letter-spacing: 0.3em; margin: 22px 0 4px; text-align: center; font-weight: 200; text-shadow: 0 0 30px rgba(138,125,255,0.35); padding-left: 0.3em; }
h1 span { color: var(--accent); font-weight: 700; text-shadow: 0 0 26px rgba(138,125,255,0.9); }
h2 { font-weight: 500; margin: 0 0 12px; letter-spacing: 0.06em; }
h3 { margin: 0 0 8px; font-weight: 500; color: var(--dim); font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; }
.sub { text-align: center; color: var(--dim); margin-bottom: 22px; }
.sub.help { font-size: 13px; margin-top: 8px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 16px; transition: background 0.1s, border-color 0.1s, transform 0.08s; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: linear-gradient(#b3a8ff, #6f5ff0); color: #111; border-color: var(--accent); font-weight: 800; font-size: 22px; letter-spacing: 0.12em; padding: 14px 56px; box-shadow: 0 0 28px rgba(138,125,255,0.45); }
.btn.primary:hover { background: #cfc8ff; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.on { border-color: var(--accent); color: var(--accent); }
.btn.danger:hover:not(:disabled) { border-color: var(--bad); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.dim { color: var(--dim); }
.accent { color: var(--accent); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.power { color: #111; background: var(--accent); border-radius: 8px; padding: 0 6px; font-size: 12px; font-weight: 700; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.matter { font-size: 18px; font-variant-numeric: tabular-nums; }
.matter b { color: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.card, .entry { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.card .name, .entry .name { font-weight: 600; }
.card .lv, .entry .lv { float: right; color: var(--dim); font-variant-numeric: tabular-nums; font-weight: 400; font-size: 13px; }
.card .desc, .entry .desc { color: var(--dim); font-size: 13px; margin: 4px 0 8px; min-height: 2.6em; }
.entry .fus { font-size: 13px; line-height: 1.5; }
.entry.locked { opacity: 0.5; }
.entry.fusion { border-color: rgba(138,125,255,0.5); }
.pips { height: 4px; background: #000; border-radius: 2px; margin: 6px 0 8px; overflow: hidden; }
.pips i { display: block; height: 100%; background: var(--accent); }
.share { display: grid; grid-template-columns: 110px 1fr 44px; gap: 10px; align-items: center; font-size: 14px; }
.share .dim { text-align: right; }

/* level-up cards */
.picks { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 6vh; }
.pick { width: 232px; background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 16px; text-align: left; transition: transform 0.08s, border-color 0.1s, box-shadow 0.1s; animation: cardin 0.18s ease-out backwards; }
.pick:nth-child(2) { animation-delay: 0.05s; } .pick:nth-child(3) { animation-delay: 0.1s; } .pick:nth-child(4) { animation-delay: 0.15s; }
@keyframes cardin { from { transform: translateY(18px); opacity: 0; } }
.pick:hover { transform: translateY(-5px); border-color: var(--accent); box-shadow: 0 8px 26px rgba(138,125,255,0.25); }
.pick .k { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; }
.pick .big-ico { font-size: 34px; line-height: 1.2; color: var(--accent); margin-top: 4px; }
.pick .t { font-size: 20px; font-weight: 700; margin: 2px 0 6px; }
.pick .d { color: var(--dim); font-size: 14px; }
.pick .h { color: #9a92d6; font-size: 12px; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.pick.fuse { border-color: var(--accent); background: linear-gradient(rgba(28,24,80,0.95), rgba(22,22,26,0.95)); box-shadow: 0 0 26px rgba(138,125,255,0.4); }
.pick.attack .k { color: #fff; }
.pick.attack { border-color: #6d6d7c; }
.pick.stat .big-ico { color: #cfcfd6; }

/* gear */
.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 14px; }
.slot { border: 1px dashed var(--line); border-radius: 10px; padding: 10px; min-height: 108px; }
.item { border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px; padding: 8px 10px; background: var(--panel); margin-bottom: 6px; }
.item .nm { font-weight: 600; }
.item .st { color: var(--dim); font-size: 13px; }
.item .acts { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
table { border-collapse: collapse; width: 100%; }
td, th { padding: 4px 8px; text-align: left; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th { color: var(--dim); font-weight: 500; font-size: 13px; }
textarea { width: 100%; height: 90px; background: #000; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-family: monospace; font-size: 11px; user-select: text; }
.win-title { font-size: 40px; text-align: center; margin: 5vh 0 6px; letter-spacing: 0.1em; font-weight: 200; }
.win-title.victory { color: var(--accent); }
.final-level { text-align: center; font-size: 18px; letter-spacing: 0.2em; color: var(--dim); margin: -6px 0 16px; }
.final-level b { font-size: 46px; color: var(--accent); letter-spacing: 0; font-weight: 800; text-shadow: 0 0 22px rgba(138,125,255,0.5); margin-left: 8px; }
.final-level .accent { font-size: 14px; }
.stat-line { display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); padding: 6px 0; }
.stat-line .dim { text-align: right; font-size: 13px; }

@media (max-width: 720px) {
  h1 { font-size: 40px; }
  #hud { padding: 8px; gap: 6px; }
  .hud-left { width: 150px; }
  .hud-right { width: 92px; font-size: 11px; }
  .lv-num { font-size: 24px; }
  .lv-gain { font-size: 13px; }
  .tier-name { font-size: 12px; }
  .tier-name small { display: none; }
  .attacks .a { font-size: 10px; padding: 1px 5px; }
  .banner { font-size: 17px; top: 24%; }
  .pick { width: 100%; padding: 12px; }
  .pick .big-ico { float: right; margin: -4px 0 0; }
  .picks { margin-top: 2vh; gap: 8px; }
  .btn.primary { padding: 14px 40px; }
}
@media (hover: hover) and (pointer: fine) {
  .dash { width: 56px; height: 56px; font-size: 10px; opacity: 0.8; }
}

/* ---- skill panel along the bottom of the screen ---- */
.skills { position: absolute; left: 12px; right: 110px; bottom: 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sk-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.sk { background: rgba(6,6,9,0.72); border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; font-size: 12px; min-width: 96px; }
.sk-top { font-weight: 600; white-space: nowrap; }
.sk-stats { color: var(--dim); font-size: 11px; white-space: nowrap; }
.sk-stats b { color: var(--text); font-weight: 600; }
.sk-pips { display: inline-flex; gap: 2px; margin-left: 4px; vertical-align: middle; }
.sk-pips i { width: 5px; height: 9px; border-radius: 2px; background: #33333c; display: block; }
.sk-pips i.on { background: var(--accent); }
.sk-bonus { color: #6fdc8c; margin-left: 5px; font-weight: 700; }
.sk.fused { border-color: var(--accent); box-shadow: 0 0 10px rgba(138,125,255,0.35); }
.sk.fused .sk-top { color: var(--accent); }
.sk.ready { border-color: #fff; }
.sk.empty { color: #5c5c66; border-style: dashed; min-width: 0; }
.sk-totals { background: rgba(6,6,9,0.6); border-radius: 8px; padding: 2px 10px; font-size: 11px; color: var(--dim); text-align: center; }
.sk-totals b { color: var(--text); }

/* ---- card rarities ---- */
.pick { border-color: var(--rar, var(--line)); }
.pick .rar { color: var(--rar); font-weight: 800; }
.pick.r1 { box-shadow: 0 0 10px rgba(111,220,140,0.25); }
.pick.r2 { box-shadow: 0 0 16px rgba(90,169,255,0.4); }
.pick.r3 { box-shadow: 0 0 22px rgba(197,139,255,0.5); background: linear-gradient(rgba(44,24,66,0.95), rgba(22,22,26,0.95)); }
.pick.r4 { box-shadow: 0 0 30px rgba(157,139,255,0.6); background: linear-gradient(rgba(30,24,84,0.95), rgba(22,22,26,0.95)); }
.pick .lines { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; color: var(--dim); }
.pick .lines li { padding: 1px 0; }
.pick .lines b { color: var(--good); }
.pick .t { color: var(--rar, var(--text)); }

/* ---- gear ---- */
.job { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; color: var(--accent); }
.trait { color: #9d8bff; font-size: 13px; margin: 2px 0; }
.setsum { font-size: 15px; }

@media (max-width: 720px) {
  .skills { right: 100px; left: 6px; bottom: 6px; }
  .sk { padding: 2px 6px; font-size: 10px; min-width: 0; }
  .sk-stats, .sk-totals { display: none; }
  .hud-center { min-width: 0; }
  .level { flex-wrap: wrap; gap: 4px; }
}

/* Explanations: help boxes, Codex hover text, crafting details */
.help-box { font-size: 13.5px; line-height: 1.5; }
.help-box > div { margin-top: 6px; }
.card.tipped { position: relative; outline: none; }
.card .desc { min-height: 0; }
.card .now { font-size: 13px; margin: 0 0 8px; }
.card .tip { display: none; position: absolute; left: -1px; right: -1px; top: 100%; z-index: 5; margin-top: 4px; padding: 10px 12px;
  background: #16161d; border: 1px solid var(--accent, #9d8bff); border-radius: 10px; font-size: 13px; line-height: 1.45; box-shadow: 0 8px 24px rgba(0,0,0,0.6); pointer-events: none; }
.card.tipped:hover .tip, .card.tipped:focus .tip, .card.tipped:focus-within .tip { display: block; }
.forge { margin-top: 8px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 8px; font-size: 13px; line-height: 1.45; }
.forge-row { margin-top: 6px; }

/* the Omen of this tier, next to the tier name */
.tier-name .omen { margin-left: 10px; font-size: 13px; font-weight: 700; letter-spacing: 0.08em; }
.tier-name .omen i { font-style: normal; font-weight: 400; letter-spacing: 0; opacity: 0.85; }
@media (max-width: 700px) { .tier-name .omen { display: block; margin: 2px 0 0; font-size: 11px; } }
/* worn gear: sits at the top of the inventory and looks locked */
.item.worn { background: linear-gradient(90deg, rgba(157,139,255, 0.14), var(--panel) 60%); border-color: var(--accent); }
.worntag { color: var(--accent); font-size: 12px; letter-spacing: 1px; border: 1px solid var(--accent); border-radius: 5px; padding: 0 5px; }
.btn.lock { opacity: 0.75; border-style: dashed; }

/* ---- 0.6.0: everything must fit on a phone held upright (412 px wide) and sideways (412 px tall) ---- */
/* messages: a dark plate so they can be read over the fight, never wider than the screen, wrapping instead of running off */
.banner { left: 50%; right: auto; transform: translateX(-50%); width: max-content; max-width: min(92vw, 640px); padding: 6px 14px;
  background: rgba(6,6,10,0.72); border: 1px solid rgba(138,125,255,0.35); border-radius: 10px; font-size: 20px; line-height: 1.25;
  white-space: normal; overflow-wrap: anywhere; text-wrap: balance; }
.bar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.tier-name { overflow-wrap: anywhere; }
.pick .k, .pick .t, .pick .d, .pick .h, .entry .name, .entry .desc, .sk-top { overflow-wrap: anywhere; }
.tabs .btn { flex: 1 1 auto; }
.ess { font-weight: 600; }
.entry .lv { margin-left: 8px; }
@media (max-width: 720px) {
  .hud-left { width: 124px; }
  .hud-right { width: 78px; }
  .banner { font-size: 15px; top: 21%; }
  .tier-name .omen i { display: none; }            /* the Omen's name only; its text is announced once and stays in the pause screen */
  .win-title { font-size: 26px !important; letter-spacing: 0.04em; margin-top: 2vh; }
  .pick .t { font-size: 17px; }
  .pick .lines { font-size: 12px; }
  .overlay { padding: 14px 10px 50px; }
  .entry .lv { float: none; display: block; margin: 0; }
}
/* sideways phone: wide but short. Keep the top of the screen small and let choice screens scroll. */
@media (max-height: 480px) {
  .banner { top: 30%; font-size: 15px; }
  .win-title { font-size: 22px !important; margin: 0 0 2px; }
  .picks { margin-top: 8px; gap: 8px; }
  .pick { width: 200px; padding: 10px; }
  .pick .big-ico { float: right; font-size: 24px; margin: -2px 0 0; }
  .pick .t { font-size: 16px; }
  .pick .lines { font-size: 12px; margin-top: 4px; }
  .sk-stats, .sk-totals { display: none; }
  .sk { padding: 2px 6px; font-size: 10px; min-width: 0; }
  .dash { width: 62px; height: 62px; bottom: 12px; }
}
@media (max-width: 720px) {
  .overlay.clear { background: rgba(8,8,11,0.86); }          /* a choice on a phone: the fight behind it must not fight the text */
  .overlay.clear .screen { padding-top: 58px; }               /* ...and the title sits below the bars at the top */
}
/* while a choice or the pause screen is open, the tier name and bar step aside so they never sit under the title */
#hud.behind .hud-center { visibility: hidden; }
@media (max-height: 480px) { .overlay.clear { background: rgba(8,8,11,0.86); } }
