/* ================================================================
   NORRTOUNIA  style.css  v1.0
   Font: IM Fell English throughout
   Layout:
     #layout-wrap (column, centred)
       #title-row   flex-row: [hero-panel | site-header | monster-panel]
       #game-area   the frame
       #controls    buttons
================================================================ */
:root{
    --ff:       'IM Fell English', Georgia, serif;
    --gold:     #c9a227;
    --amber:    #e8c45a;
    --blood:    #8a0000;
    --white:    #ffffff;
    --dim1:     rgba(255,255,255,0.80);
    --dim2:     rgba(255,255,255,0.54);
    --dim3:     rgba(255,255,255,0.30);
    --dim4:     rgba(255,255,255,0.14);
    --greensub: #3d7520;
    --border:   rgba(120,90,40,0.35);
    --goldbdr:  rgba(201,162,39,0.72);
    /* portrait card — fixed width AND height so cards never shift size */
    --card-w:   78px;
    --card-h:  188px;
    --sprite-w: 66px;
    --sprite-h: 84px;
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0;}

html{
    height:100%;
    background:#000;
    /* Allow the page to scroll on small screens */
    overflow-y:auto;
    overflow-x:hidden;
}
body{
    min-height:100%;
    background:#000;
    color:var(--white);
    font-family:var(--ff);
    display:flex;
    flex-direction:column;
    align-items:center;
    /* Centre vertically when there is room, scroll when there is not */
    justify-content:center;
    overflow:visible;
    padding:6px 8px 10px;
    gap:3px;
}

/* ── Single column wrapper — same width as frame ── */
#layout-wrap{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:3px;
    /* Width scales with viewport height on large screens, 
       but uses full width on small/narrow screens */
    width:min(98vw, calc((100vh - 100px) * 1376 / 768));
    overflow:visible;
    /* Prevent the wrapper itself from being taller than its content */
    box-sizing:border-box;
}

/* ══════════════════════════════════════════════════
   TITLE ROW
   Three columns: hero-panel | site-header | monster-panel
   hero-panel and monster-panel are flex:1 so the title
   stays locked to the absolute centre of the row.
══════════════════════════════════════════════════ */
#title-row{
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding-bottom: 2px;
    overflow: visible;
}

/* Left flank — heroes right-aligned inside so they sit next to title */
#hero-panel{
    flex: 1;
    display: flex;
    flex-direction: row;
    gap: 4px;
    align-items: center;
    justify-content: flex-end;   /* portraits hug the title */
    min-width: 0;
}

/* Right flank — monster left-aligned inside so it sits next to title */
#monster-panel{
    flex: 1;
    display: flex;
    flex-direction: row;
    gap: 4px;
    align-items: center;
    justify-content: flex-start; /* portrait hugs the title */
    min-width: 0;
}
.monster-selectable{ cursor: pointer; }
.monster-selectable:hover{ border-color: rgba(180,50,50,.85) !important; }
.monster-targeted{
    border-color: var(--gold) !important;
    box-shadow: 0 0 10px rgba(201,162,39,0.40);
}

/* Centre — title block, never squished */
#site-header{
    flex-shrink: 0;
    text-align: center;
    white-space: nowrap;
}
#game-title{
    font-family: var(--ff);
    font-weight: 400;
    font-size: clamp(20px, 2.9vw, 38px);
    color: var(--gold);
    letter-spacing: 4px;
    text-shadow:
        0 0 20px rgba(201,162,39,0.72),
        0 0 45px rgba(201,162,39,0.40),
        2px 2px 0 #000;
    animation: titleGlow 4s ease-in-out infinite alternate;
}
@keyframes titleGlow{
    from{ text-shadow: 0 0 14px rgba(201,162,39,0.60), 0 0 30px rgba(201,162,39,0.25), 2px 2px 0 #000; }
    to  { text-shadow: 0 0 32px rgba(201,162,39,0.95), 0 0 65px rgba(201,162,39,0.55), 0 0 95px rgba(201,162,39,0.20), 2px 2px 0 #000; }
}
#game-sub{
    font-family: var(--ff);
    font-size: clamp(12px, 1.15vw, 16px);
    color: var(--greensub);
    letter-spacing: 2px;
    margin-top: 2px;
}
#version{
    color: var(--dim2);
    font-size: 0.85em;
}

/* ══════════════════════════════════════════════════
   PORTRAIT CARD
   Order top→bottom:
     1. crown (absolute, overflows top)
     2. sprite with status-overlay
     3. hp-bar
     4. name  (gold)
     5. class · level (dim white)
     6. item icons (max 4)
══════════════════════════════════════════════════ */
.portrait-card{
    width: var(--card-w);
    height: var(--card-h);
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #000;
    border: 1px solid var(--border);
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
    transition: border-color .18s;
}
.portrait-card:hover    { border-color: var(--goldbdr); }
.portrait-dead          { opacity: .50; filter: grayscale(.60); }
.monster-card           { border-color: rgba(138,0,0,.45); }
.monster-card:hover     { border-color: rgba(200,50,30,.80); }

/* 1. Crown */
.leader-crown{
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(11px, 1.1vw, 14px);
    line-height: 1;
    pointer-events: none;
    filter: drop-shadow(0 1px 4px rgba(0,0,0,1));
    z-index: 20;
    opacity: .90;
}

/* 2. Sprite */
.portrait-sprite-wrap{
    position: relative;
    width: var(--sprite-w);
    height: var(--sprite-h);
    flex-shrink: 0;
}
.portrait-sprite{ display: block; image-rendering: pixelated; }
.portrait-dead-x{
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5em; color: var(--blood);
    background: rgba(0,0,0,.55);
}
/* Status icons overlaid bottom-left of sprite */
.status-overlay{
    position: absolute;
    bottom: 2px; left: 2px;
    display: flex; flex-wrap: wrap; gap: 1px;
    max-width: calc(var(--sprite-w) - 4px);
}
.status-icon{
    font-size: clamp(10px, 1.0vw, 13px);
    line-height: 1;
    cursor: help;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.9));
    position: relative;
}
.status-icon .si-tip{
    display: none;
    position: absolute;
    bottom: calc(100% + 5px); left: 0;
    z-index: 500;
    min-width: 150px; max-width: 230px;
    background: #000;
    border: 1px solid var(--goldbdr);
    padding: 6px 9px;
    font-family: var(--ff);
    font-size: clamp(11px, .95vw, 15px);
    line-height: 1.65;
    color: var(--white);
    white-space: normal; pointer-events: none;
    box-shadow: 0 3px 12px rgba(0,0,0,.9);
    text-align: left;
}
.status-icon:hover .si-tip{ display: block; }

/* 3. HP bar */
.portrait-hp-wrap{
    width: 100%; height: 6px;
    background: rgba(255,255,255,.08);
    flex-shrink: 0; cursor: help;
    position: relative;
}
.portrait-hp-bar{
    height: 100%;
    transition: width .35s ease, background .35s;
    min-width: 2px;
}
.hp-tip{
    display: none;
    position: absolute;
    bottom: calc(100% + 5px); left: 50%; transform: translateX(-50%);
    z-index: 500;
    background: #000; border: 1px solid var(--goldbdr);
    padding: 4px 9px;
    font-family: var(--ff); font-size: clamp(11px, .95vw, 15px);
    color: var(--white); white-space: nowrap; pointer-events: none;
    box-shadow: 0 3px 10px rgba(0,0,0,.88);
}
.portrait-hp-wrap:hover .hp-tip{ display: block; }

/* 4. Name — gold */
.pi-name{
    font-family: var(--ff);
    font-size: clamp(8px, .78vw, 11px);
    color: var(--gold);
    text-align: center;
    padding: 2px 3px 0;
    display: block; width: 100%;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    text-shadow: 1px 1px 0 #000;
    cursor: help;
    position: relative;
    flex-shrink: 0;
}
.pi-name-monster{ color: #ff7777 !important; }

/* 5. Race / Level / Class lines — white */
.pi-sub{
    font-family: var(--ff);
    font-size: clamp(7px, .62vw, 9px);
    color: var(--white);
    text-align: center;
    padding: 0 3px 0;
    display: block;
    /* flex: 1 means it fills all remaining vertical space between name and items */
    flex: 1;
    min-height: 0;
    overflow: hidden;
    line-height: 1.30;
    text-shadow: 1px 1px 0 #000;
    cursor: help;
    position: relative;
    width: 100%;
}

/* Spacer kept in markup but no longer needed for layout */
.pi-gap{ display: none; }

/* 6. Item icons — always at the bottom */
.pi-items{
    display: flex; flex-wrap: nowrap; gap: 2px;
    justify-content: center;
    padding: 2px 2px 3px;
    height: 20px;           /* fixed — guaranteed space for 4 icons */
    width: 100%;
    flex-shrink: 0;
    align-items: center;
    border-top: 1px solid rgba(255,255,255,.05);
}
.pi-item-icon{
    font-size: clamp(11px, 1.0vw, 13px);
    cursor: help; line-height: 1;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.8));
    position: relative;
    flex-shrink: 0;
}
.pi-item-icon .item-tip{
    display: none;
    position: absolute;
    bottom: calc(100% + 5px); left: 50%; transform: translateX(-50%);
    z-index: 500;
    min-width: 155px; max-width: 240px;
    background: #000; border: 1px solid var(--goldbdr);
    padding: 6px 10px;
    font-family: var(--ff); font-size: clamp(11px, .95vw, 15px);
    line-height: 1.65; color: var(--white);
    white-space: normal; pointer-events: none;
    box-shadow: 0 3px 12px rgba(0,0,0,.88);
    text-align: left;
}
.pi-item-icon:hover .item-tip{ display: block; }

/* Slain */
.pi-dead{
    font-family: var(--ff);
    font-size: clamp(8px, .72vw, 11px);
    color: var(--blood); text-align: center;
    padding: 4px 2px;
    text-shadow: 0 0 6px rgba(138,0,0,.6);
    display: block;
}

/* Stat tooltip (on name / sub hover) */
.stat-tooltip{
    display: none;
    position: absolute;
    bottom: calc(100% + 5px); left: 50%; transform: translateX(-50%);
    z-index: 600;
    min-width: 190px; max-width: 270px;
    background: #000; border: 1px solid var(--goldbdr);
    padding: 8px 10px;
    font-family: var(--ff); font-size: clamp(11px, .95vw, 15px);
    line-height: 1.70; color: var(--white);
    white-space: normal; pointer-events: none;
    box-shadow: 0 4px 18px rgba(0,0,0,.90);
    text-align: left;
}
.pi-name:hover  .stat-tooltip,
.pi-sub:hover   .stat-tooltip{ display: block; }

/* Morality change flash — green for gain, red for loss */
.moral-flash{
    position: absolute;
    top: 42%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-family: var(--ff);
    font-size: clamp(9px, .88vw, 13px);
    font-weight: bold;
    pointer-events: none;
    z-index: 301;
    text-shadow: 0 0 5px rgba(0,0,0,1), 1px 1px 0 #000;
    animation: moralFloat 2.2s ease-out forwards;
}
@keyframes moralFloat{
    0%  { opacity:1; transform: translateX(-50%) translateY(0)    scale(1.20); }
    18% {            transform: translateX(-50%) translateY(-6px)  scale(1.00); opacity:1; }
    65% { opacity:.80; }
    100%{ opacity:0; transform: translateX(-50%) translateY(-34px) scale(.85); }
}

/* Stat-flash level-up */
.stat-flash{
    position: absolute; top: 18%; left: 50%; transform: translateX(-50%);
    white-space: nowrap;
    font-family: var(--ff); font-size: clamp(8px, .78vw, 11px);
    pointer-events: none; z-index: 300;
    animation: floatUp 2.4s ease-out forwards;
}
@keyframes floatUp{
    0%  { opacity:1; transform: translateX(-50%) translateY(0); }
    65% { opacity:1; }
    100%{ opacity:0; transform: translateX(-50%) translateY(-40px); }
}

/* ══════════════════════════════════════════════════
   GAME AREA + FRAME
══════════════════════════════════════════════════ */
#game-area{
    width: 100%;
    position: relative;
}
#portrait-strip{ display: none !important; } /* legacy, always hidden */

#frame-wrap{
    position: relative;
    width: 100%;
    aspect-ratio: 1376 / 768;
    background: url('frame.jpg') no-repeat center / 100% 100%;
}
#fog{
    position: absolute;
    left: 30.16%; top: 24.09%; width: 39.83%; height: 52.08%;
    pointer-events: none;
    background: radial-gradient(ellipse 50% 40% at 50% 35%, transparent 30%, rgba(0,0,0,.65) 100%);
    z-index: 6;
    animation: fogPulse 9s ease-in-out infinite alternate;
}
@keyframes fogPulse{ from{opacity:.25;} to{opacity:.65;} }

.shake{ animation: shakeAnim .30s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shakeAnim{
    15%,85%{ transform: translate(-2px, 2px); }
    30%,70%{ transform: translate( 3px,-3px); }
    50%    { transform: translate(-4px, 4px); }
    60%    { transform: translate( 4px,-4px); }
}

#game-window{
    position: absolute;
    left: 30.16%; top: 24.09%; width: 39.83%; height: 52.08%;
    z-index: 10;
    display: flex; flex-direction: column;
    overflow: hidden;
    padding: 1.6% 2.2%;
}
.screen{ display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.hidden{ display: none !important; }

/* ══════════════════════════════════════════════════
   INTRO SCREEN
══════════════════════════════════════════════════ */
#intro-text{
    display: flex; flex-direction: column; gap: 3%;
    flex: 1; overflow-y: auto; scrollbar-width: none;
    justify-content: flex-start; padding: 4% 0 2%;
}
#intro-text::-webkit-scrollbar{ display: none; }
.intro-line{
    font-family: var(--ff);
    font-size: clamp(11px, .92vw, 15px);
    line-height: 1.80; color: var(--white); text-shadow: 1px 1px 0 #000;
}
.intro-gold{ color: #c9a227 !important; text-shadow: 0 0 12px rgba(201,162,39,0.50), 1px 1px 0 #000 !important; }
.intro-dim { color: var(--dim2) !important; }
#team-name-wrap{
    flex-shrink: 0; display: flex; align-items: center;
    gap: 8px; padding-top: 3%; flex-wrap: wrap; justify-content: center;
}
#btn-scores{
    font-size: 1.15em; padding: 2px 7px;
    background: transparent; border-color: rgba(201,162,39,.35);
    color: var(--gold); opacity: .75;
}
#btn-scores:hover{ opacity: 1; border-color: var(--gold); }
.team-label{
    font-family: var(--ff);
    font-size: clamp(11px, .90vw, 14px);
    color: var(--gold); white-space: nowrap;
}
.team-input{
    background: rgba(0,0,0,.80);
    border: 1px solid rgba(201,162,39,.45);
    color: var(--white);
    font-family: var(--ff);
    font-size: clamp(11px, .90vw, 14px);
    padding: 5px 8px; outline: none;
    width: min(200px,55%);
    text-align: center; letter-spacing: 1px;
}
.team-input:focus{ border-color: var(--gold); box-shadow: 0 0 8px rgba(201,162,39,.28); }
.team-input::placeholder{ color: var(--dim3); }

/* ══════════════════════════════════════════════════
   SETUP SCREEN
══════════════════════════════════════════════════ */
#party-slots{
    display: flex; gap: 2%;
    flex: 1; min-height: 0; padding: 2% 0;
}
.slot-card{
    flex: 1; background: #000;
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-start;
    gap: 4px; padding: 6px 4%;
    text-align: center;
    font-family: var(--ff);
    font-size: clamp(9px, .82vw, 13px);
    line-height: 1.50; text-shadow: 1px 1px 0 #000;
    border: 1px solid var(--border);
    transition: border-color .18s;
    overflow: hidden;
}
.slot-card:hover         { border-color: var(--goldbdr); }
.slot-card.locked        { border-color: rgba(62,107,21,.60); }
.slot-name{
    color: var(--gold);
    font-size: clamp(10px, .88vw, 14px);
    display: block;
    line-height: 1.35;
    word-break: break-word;
}
.slot-sub {
    color: var(--dim1); display: block;
    font-size: clamp(8px, .72vw, 11px);
    line-height: 1.40;
}
.slot-stats{
    color: var(--white); display: block;
    font-size: clamp(8px, .72vw, 11px);
}
.ability-hint{
    font-size: clamp(8px, .70vw, 11px) !important;
    color: #9966dd !important;
    position: relative;
}

/* ── Alignment line ────────────────────────────── */
.slot-align {
    display: block;
    font-size: clamp(8px, .70vw, 11px);
    letter-spacing: .03em;
    cursor: help;
    border-bottom: 1px dotted rgba(255,255,255,.10);
    padding-bottom: 2px;
    width: 100%;
}

/* ── Stat grid ─────────────────────────────────── */
.slot-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px 6px;
    width: 100%;
    padding: 2px 0;
}
.sg-cell {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 1px 2px;
    border-bottom: 1px solid rgba(255,255,255,.05);
}
.sg-label {
    color: rgba(200,192,176,.45);
    font-size: clamp(7px, .58vw, 9px);
    letter-spacing: .06em;
    text-transform: uppercase;
}
.sg-num {
    color: var(--white);
    font-size: clamp(11px, 1.0vw, 16px);
    font-weight: bold;
    line-height: 1;
    text-shadow: 0 0 6px rgba(255,255,255,.12);
}
.sg-hp  { color: #5cbf40; }
.sg-primary .sg-num { color: #88ccff; text-shadow: 0 0 6px rgba(136,204,255,.30); }

/* ── Badge row ─────────────────────────────────── */
.slot-badges {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 2px;
}
.slot-badge {
    background: rgba(255,255,255,.03);
    border: 1px solid var(--border);
    padding: 2px 7px;
    font-size: clamp(8px, .65vw, 10px);
    color: var(--dim1);
    cursor: help;
    transition: border-color .15s, color .15s;
    white-space: nowrap;
}
.slot-badge:hover              { border-color: var(--goldbdr); color: var(--gold); }
.slot-badge-abil               { color: rgba(153,102,221,.80); border-color: rgba(153,102,221,.25); }
.slot-badge-abil:hover         { border-color: #9966dd; color: #c89eff; }
.slot-badge-res                { color: rgba(255,119,51,.80); border-color: rgba(255,119,51,.25); }
.slot-badge-res:hover          { border-color: #ff7733; color: #ffaa77; }
.setup-ability-hint{ cursor: help; position: relative; }
.setup-tooltip{
    display: none;
    position: absolute;
    bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
    z-index: 500;
    min-width: 190px; max-width: 270px;
    background: #000; border: 1px solid var(--goldbdr);
    padding: 7px 10px;
    font-family: var(--ff); font-size: clamp(11px, .95vw, 15px);
    line-height: 1.70; color: var(--white);
    white-space: normal; pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,.85);
    text-align: left;
}
.setup-ability-hint:hover .setup-tooltip{ display: block; }

.bind-btn{
    background: #000;
    border: 1px solid var(--border);
    color: var(--white);
    font-family: var(--ff);
    font-size: clamp(8px, .72vw, 11px);
    padding: 4px 8px; cursor: pointer;
    transition: all .18s; text-shadow: 1px 1px 0 #000;
    margin-top: auto;
    flex-shrink: 0;
    width: 100%;
}
.bind-btn:hover{ border-color: var(--goldbdr); color: var(--amber); }
.slot-card.locked .bind-btn{
    border-color: rgba(62,107,21,.80); color: #7dbc3a;
    box-shadow: 0 0 8px rgba(61,107,21,.70), 0 0 18px rgba(61,107,21,.30);
}

/* ══════════════════════════════════════════════════
   PLAY SCREEN — log
══════════════════════════════════════════════════ */
#game-log{
    flex: 1; overflow-y: auto; scrollbar-width: none; min-height: 0;
    display: flex; flex-direction: column-reverse;
    padding: 3px 2px;
    font-family: var(--ff);
    font-size: clamp(12px, 1.00vw, 16px);
    line-height: 1.72;
}
#game-log::-webkit-scrollbar{ display: none; }

/* Log text: all white, no fading. Current prompt is larger and highlighted. */
#game-log p            { margin: 0 0 1px; text-shadow: 1px 1px 0 #000; color: var(--white); }
#game-log p.log-recent { color: var(--white) !important; }
#game-log p.log-age-1,
#game-log p.log-age-2,
#game-log p.log-age-3  { color: var(--white) !important; }
#game-log p.prompt-current{
    color: var(--white) !important;
    border-left: 3px solid var(--gold);
    padding-left: 6px; margin-left: -6px;
    background: rgba(255,255,255,.04);
    font-size: 1.22em;
    font-weight: normal;
    letter-spacing: 0.3px;
}
/* Only spoken dialogue is italic */
#game-log p.log-speech { font-style: italic; }
#game-log p.log-blood  { color: var(--blood) !important; }
#game-log p.log-spacer { height: .55em; color: transparent; pointer-events: none; flex-shrink: 0; }

/* Inline tooltip for items/spells in log */
.log-item-tip{
    position: relative; cursor: help;
    text-decoration: underline dotted rgba(201,162,39,.45);
}
.log-item-tip:hover .log-inline-tip{ display: block; }
.log-inline-tip{
    display: none;
    position: absolute;
    bottom: calc(100% + 3px); left: 0;
    z-index: 9999;
    z-index: 600;
    min-width: 150px; max-width: 230px;
    background: #000; border: 1px solid var(--goldbdr);
    padding: 5px 9px;
    font-family: var(--ff); font-size: clamp(11px, .95vw, 15px);
    line-height: 1.65; color: var(--white);
    white-space: normal; pointer-events: none;
    box-shadow: 0 3px 12px rgba(0,0,0,.88);
    font-style: italic;
}

/* Treasury bar */
#treasury-bar{
    flex-shrink: 0;
    font-family: var(--ff);
    font-size: clamp(11px, .92vw, 15px);
    color: var(--white);
    text-align: center; padding-top: 1.5%;
    text-shadow: 1px 1px 0 #000;
    display: flex; gap: 10px; justify-content: center;
    align-items: center; flex-wrap: wrap;
}
.tbar-turn  { color: #aaaaaa; font-size: 0.90em; }
.tbar-gold  { color: #c9a227; }
.tbar-gem   { color: #55ddff; }
.tbar-total { color: #e8c45a; font-weight: normal; }

/* ══════════════════════════════════════════════════
   END SCREEN
══════════════════════════════════════════════════ */
#screen-end{ align-items: center; gap: 4%; }
#end-title{
    flex-shrink: 0;
    font-family: var(--ff);
    font-size: clamp(15px, 1.30vw, 21px);
    text-shadow: 1px 1px 0 #000; text-align: center;
}
#end-flavour{
    flex-shrink: 0;
    font-family: var(--ff); font-style: italic;
    font-size: clamp(11px, .92vw, 15px);
    color: var(--dim1); text-align: center;
    line-height: 1.75; padding: 0 4%;
}
#screen-end.victory #end-title{ color: var(--gold); animation: victoryGlow 2.5s ease-in-out infinite; }
@keyframes victoryGlow{
    0%,100%{ text-shadow: 0 0 8px  rgba(201,162,39,.4), 2px 2px 0 #000; }
    50%    { text-shadow: 0 0 30px rgba(201,162,39,.9), 0 0 55px rgba(201,162,39,.3), 2px 2px 0 #000; }
}
#screen-end.defeat #end-title{ color: var(--blood); animation: defeatPulse 3.5s ease-in-out infinite; }
@keyframes defeatPulse{ 0%,100%{opacity:1;} 50%{opacity:.4;} }
#highscore-list{
    flex: 1; overflow-y: auto; scrollbar-width: none; width: 100%;
    font-family: var(--ff);
    font-size: clamp(11px, .92vw, 15px);
    line-height: 2.1; text-align: center; min-height: 0;
}
#highscore-list::-webkit-scrollbar{ display: none; }
#highscore-list p{ margin: 0; }

/* ══════════════════════════════════════════════════
   CONTROLS
══════════════════════════════════════════════════ */
#controls{
    flex-shrink: 0; width: 100%;
    display: flex; justify-content: center; gap: 6px;
}
#ctrl-intro, #ctrl-setup, #ctrl-play, #ctrl-end{
    display: flex; gap: 6px; flex-wrap: wrap;
    justify-content: center; width: 100%;
}
.px-btn{
    background: #000;
    border: 1px solid var(--border);
    color: var(--white);
    font-family: var(--ff);
    font-size: clamp(11px, .98vw, 15px);
    padding: 7px 14px; cursor: pointer;
    text-align: left; text-shadow: 1px 1px 0 #000;
    transition: border-color .12s, color .12s;
    line-height: 1.5; white-space: nowrap;
    position: relative; overflow: visible;
}
.px-btn:hover, .px-btn:focus-visible{
    border-color: var(--goldbdr); color: var(--amber); outline: none;
}
.gold-btn{ border-color: rgba(201,162,39,.55); color: var(--gold); }
.gold-btn:hover{ border-color: var(--amber); color: var(--amber); }
#ctrl-play .px-btn{
    white-space: normal; text-align: left;
    font-size: clamp(10px, .92vw, 14px);
}
.gated-btn           { border-color: rgba(201,162,39,.65) !important; color: var(--amber) !important; }
.ability-cooldown    { opacity: .42; cursor: not-allowed !important; color: var(--dim3) !important; }

/* Choice probability tooltip above each button */
.choice-tip{
    display: none;
    position: absolute;
    bottom: calc(100% + 5px); left: 50%; transform: translateX(-50%);
    z-index: 700;
    min-width: 165px; max-width: 255px;
    background: #000; border: 1px solid var(--goldbdr);
    padding: 6px 10px;
    font-family: var(--ff); font-size: clamp(11px, .95vw, 15px);
    color: var(--white); text-shadow: 1px 1px 0 #000;
    white-space: normal; text-align: left; pointer-events: none;
    box-shadow: 0 3px 14px rgba(0,0,0,.90); line-height: 1.55;
}
.px-btn:hover .choice-tip{ display: block; }

/* ── Button colour variants for action state ── */
.btn-cooldown{
    color: #cc4444 !important;
    border-color: rgba(180,40,40,0.45) !important;
    opacity: 0.70;
}
.btn-flee{
    color: #aaaaaa !important;
    border-color: rgba(100,100,100,0.40) !important;
    font-style: italic;
}
/* Remove old CSS tooltip remnants — all tooltips are now JS-driven */
.stat-tooltip, .si-tip, .item-tip, .hp-tip, .setup-tooltip, .choice-tip,
.log-inline-tip, .log-item-tip { display:none !important; }

/* ══════════════════════════════════════════════════
   DICE OVERLAY — shown on portrait card during action
══════════════════════════════════════════════════ */
.dice-overlay{
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    pointer-events: none;
    border: 1px solid rgba(201,162,39,.30);
}
.dice-spin{
    font-family: var(--ff);
    font-size: clamp(22px, 2.5vw, 30px);
    font-weight: bold;
    color: rgba(201,162,39,.55);
    line-height: 1;
    display: block;
}
.dice-result{
    font-family: var(--ff);
    font-size: clamp(24px, 2.7vw, 32px);
    font-weight: bold;
    line-height: 1;
    display: block;
    text-shadow: 0 0 16px currentColor;
    animation: diceSettle .22s ease-out;
}
.dice-tier{
    font-family: var(--ff);
    font-size: clamp(6px, .55vw, 8px);
    margin-top: 4px;
    text-align: center;
    letter-spacing: .05em;
    display: block;
}
@keyframes diceSettle{
    from{ transform: scale(1.45); opacity:.20; }
    to  { transform: scale(1.00); opacity:1.0; }
}
