:root {
    --top: calc(env(safe-area-inset-top) + 56px);
    --bottom: calc(env(safe-area-inset-bottom) + 12px);
    --left: calc(env(safe-area-inset-left) + 10px);
    --right: calc(env(safe-area-inset-right) + 6px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    background: #000;
    font-family: "Trebuchet MS", Verdana, sans-serif;
}

canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
}

#hud {
    position: fixed;
    z-index: 10;
    pointer-events: none;
    left: var(--left);
    top: calc(var(--top) + 8px);
    color: #eaf6ff;
    text-shadow: 0 2px 6px #001628;
}

.coins {
    font-size: clamp(20px, 5.6vw, 30px);
    font-weight: bold;
    color: #ffd75e;
    letter-spacing: .5px;
}

.sub {
    font-size: clamp(11px, 3.1vw, 15px);
    opacity: .9;
    margin-top: 2px;
}

/* one text node. A dot per species was already crowding a 320px screen at 14 of them, and
   at 34 there is no layout that fits — the number is the readout. */
#dex {
    margin-top: 6px;
    font-size: clamp(11px, 3.1vw, 15px);
    color: #a8e0ff;
    opacity: .9;
}

/* sits in the headroom --top reserves, above the coins/luck row — a centred line at that row
   collides with the "next: Bamboo Rod · 25c" text on a 320px screen. Never cycle-tinted: a
   readout that dims at night is a readout you cannot read at night. */
#clock {
    position: fixed;
    z-index: 10;
    left: 50%;
    transform: translateX(-50%);
    top: calc(env(safe-area-inset-top) + 30px);
    pointer-events: none;
    color: #cfe9ff;
    font-size: clamp(10px, 2.8vw, 13px);
    letter-spacing: 1.5px;
    opacity: .8;
    text-shadow: 0 2px 6px #001628;
}

#luck {
    position: fixed;
    z-index: 10;
    right: var(--right);
    top: calc(var(--top) + 8px);
    color: #ffe9a0;
    font-weight: bold;
    font-size: clamp(13px, 3.6vw, 16px);
    pointer-events: none;
    text-shadow: 0 2px 6px #001628;
}

#line-label {
    position: fixed;
    z-index: 10;
    right: var(--right);
    top: calc(var(--top) + 42px);
    color: #a8e0ff;
    font-size: 11px;
    letter-spacing: 1px;
    pointer-events: none;
}

#line-wrap {
    position: fixed;
    z-index: 10;
    right: calc(env(safe-area-inset-right) + 12px);
    top: calc(var(--top) + 62px);
    width: clamp(13px, 3.4vw, 17px);
    height: 26vh;
    background: rgba(8, 32, 52, .85);
    border: 2px solid #4d8cb0;
    border-radius: 10px;
    overflow: hidden;
    pointer-events: none;
}

#line-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0%;
    background: linear-gradient(180deg, #ff4d6d, #ffb03a);
    transition: height .06s linear;
}

.shop-btn {
    position: fixed;
    z-index: 10;
    bottom: var(--bottom);
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto;
    border-radius: 16px;
    padding: 10px 18px;
    font-size: clamp(13px, 3.6vw, 16px);
    font-weight: bold;
    font-family: inherit;
    letter-spacing: 2px;
    background: linear-gradient(160deg, #1a4a68, #0a2236);
    border: 2px solid #4d94bc;
    color: #dff0ff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
}

#shop-btn.can {
    border-color: #ffd75e;
    color: #ffe9a0;
    animation: pulse 1.1s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 215, 94, .5); }
    50% { box-shadow: 0 0 0 9px rgba(255, 215, 94, 0); }
}

/* Bottom-right, clear of the shop button and the hint, which are both centred. z-index 21 is
   deliberate: every other HUD element is 10 and correctly disappears behind the shop panel at
   20, and the mute is the one control that has to stay reachable while shopping. */
.mute-btn {
    position: fixed;
    z-index: 21;
    bottom: var(--bottom);
    right: var(--right);
    pointer-events: auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    font-family: inherit;
    background: linear-gradient(160deg, #1a4a68, #0a2236);
    border: 2px solid #4d94bc;
    color: #dff0ff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
}

.mute-btn.off {
    border-color: #6d7f8c;
    opacity: .62;
}

/* Menu layer. 0/10 are canvas / hud, so the screen takes 20. */
.screen {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    color: #eaf6ff;
    background: radial-gradient(ellipse at 50% 45%, rgba(4, 7, 22, .62), rgba(3, 5, 16, .93));
    pointer-events: none;
}

.screen.on { display: flex; }

.screen h1 {
    margin: 0 0 6px;
    font-size: clamp(22px, 5vw, 36px);
    letter-spacing: 4px;
    color: #9cecff;
    text-shadow: 0 0 26px rgba(60, 190, 255, .85);
}

.screen p {
    margin: 4px 0;
    font-size: clamp(11px, 2.6vw, 14px);
    letter-spacing: 2px;
    opacity: .72;
    max-width: 36ch;
    line-height: 1.7;
}

.screen .credits {
    margin-top: 12px;
    letter-spacing: 3px;
    opacity: .88;
}

.screen .credits span {
    color: #ffd24a;
    font-weight: 900;
    text-shadow: 0 0 14px rgba(255, 170, 40, .8);
}

.screen .note {
    margin-top: 12px;
    font-size: 10px;
    letter-spacing: 2px;
    opacity: .45;
}

.screen .hint {
    margin-top: 18px;
    font-size: 10px;
    opacity: .55;
}

/* the control lines the player cannot act on are removed, not dimmed — keyboard shortcuts
   on a phone are noise. The body class is set from Input.touchMode and flips at runtime. */
.only-touch, .only-mouse { display: none; }
body.mouse .only-mouse { display: block; }
body.touch .only-touch { display: block; }

/* centred like the other games' title screens. `safe center` is the one difference: on a
   short landscape phone the copy is taller than the viewport, and plain centring puts the
   overflow above the scroll origin where it can never be reached. pointer-events is
   required or a tap on the backdrop falls through to the canvas and holds the hook down
   while the sim is frozen behind the panel. */
#screen-intro {
    justify-content: center;
    justify-content: safe center;
    overflow-y: auto;
    touch-action: pan-y;
    pointer-events: auto;
}

.screen .shop-head {
    width: min(440px, 100%);
    max-width: none;
    margin: 16px 0 2px;
    text-align: left;
    font-size: 9px;
    letter-spacing: 4px;
    opacity: .45;
}

/* The shop can outgrow a short viewport, and body{touch-action:none} would otherwise
   swallow the drag, so the scroll is re-enabled on this screen only. */
#screen-shop {
    justify-content: flex-start;
    padding: 6vh 20px 26px;
    overflow-y: auto;
    touch-action: pan-y;
    pointer-events: auto;
}

/* fixed, not absolute: the panel scrolls, and an absolute child would ride the list off
   the top the moment the player scrolls down to the supplies */
.screen-x {
    position: fixed;
    z-index: 21;
    top: calc(env(safe-area-inset-top) + 10px);
    right: calc(env(safe-area-inset-right) + 10px);
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    pointer-events: auto;
    font-family: inherit;
    font-size: 24px;
    line-height: 1;
    color: #dff0ff;
    background: linear-gradient(160deg, #1a4a68, #0a2236);
    border: 2px solid #4d94bc;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
    cursor: pointer;
}

.screen-x:hover { background: linear-gradient(160deg, #266b95, #0d2c44); }

/* sized against the container, not the viewport: #screen-shop carries 20px of padding a
   side, so 90vw is wider than the box it sits in and the whole shop scrolls sideways */
#shop-rods, #shop-baits, #shop-gear, #shop-supplies { width: min(440px, 100%); }

.shop-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: min(440px, 100%);
    margin: 7px 0;
    padding: 11px 14px;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: 9px;
    background: rgba(255, 255, 255, .04);
}

.shop-info {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
    line-height: 1.2;
}

.shop-name {
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 2px;
    color: #9cecff;
}

.shop-desc {
    font-size: 10px;
    letter-spacing: 1px;
    opacity: .72;
}

.btn {
    pointer-events: auto;
    font-family: inherit;
    font-size: 11px;
    letter-spacing: 2px;
    font-weight: 700;
    color: #eaf6ff;
    background: rgba(120, 200, 255, .08);
    border: 1px solid rgba(120, 200, 255, .5);
    border-radius: 7px;
    padding: 9px 14px;
    cursor: pointer;
    transition: background .12s linear, opacity .12s linear;
}

.btn:hover:not(:disabled) { background: rgba(120, 200, 255, .22); }
.btn:disabled { opacity: .3; cursor: default; border-color: rgba(255, 255, 255, .18); }

.btn.wide {
    margin-top: 12px;
    min-width: 170px;
    padding: 12px 18px;
}

.btn.buy { min-width: 96px; text-align: center; }

#banner {
    position: fixed;
    z-index: 11;
    left: 0;
    right: 0;
    top: 36%;
    text-align: center;
    pointer-events: none;
    color: #fff;
    font-size: clamp(22px, 6.6vw, 34px);
    font-weight: bold;
    text-shadow: 0 3px 12px #000;
    opacity: 0;
}

/* Bottom-left: the shop button is centred and the mute is bottom-right, so this is the only
   corner left. max-width keeps it clear of the centred button's left edge on a 320px screen. */
#stock {
    position: fixed;
    z-index: 10;
    left: var(--left);
    bottom: calc(var(--bottom) + 12px);
    max-width: 40vw;
    overflow: hidden;
    white-space: nowrap;
    color: #cdeeff;
    font-size: clamp(11px, 3.1vw, 15px);
    opacity: .9;
    pointer-events: none;
    text-shadow: 0 2px 8px #001628;
}

#hint {
    position: fixed;
    z-index: 10;
    left: 0;
    right: 0;
    bottom: calc(var(--bottom) + 76px);
    text-align: center;
    color: #cdeeff;
    font-size: clamp(12px, 3.4vw, 16px);
    pointer-events: none;
    text-shadow: 0 2px 8px #001628;
}
