:root{
    /* The sea's visible height in world units; main.js sets it to fit the screen (the width is always 400). */
    --world-height: 700;
    --text: #f4fbff;
    --text-muted: #b9d8ee;
    --accent: #ffd23f;
    --accent-text: #0b2a4a;
    --card: rgba(8, 36, 70, .86);
    --dialog: #0f3360;
    --font: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
}

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html{
    touch-action: manipulation;
}

body{
    min-height: 100dvh;
    background: #0b2a4a linear-gradient(180deg, #1f8bd0, #071a33) no-repeat;
    color: var(--text);
    font-family: var(--font);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.noscript{
    padding: 24px;
    font-size: 18px;
}

.noscript a{
    color: var(--accent);
}

/* Fills the screen and keeps clear of the iPhone notch and home bar. */
.app{
    position: fixed;
    inset: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    user-select: none;
    -webkit-user-select: none;
}

/* A size container, so the screen can fit it in both directions. */
.stage{
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    container-type: size;
}

/* Keeps the sea's shape: the whole phone screen, or a tall column on a computer. */
.screen{
    position: relative;
    width: min(100cqw, 100cqh * 400 / var(--world-height));
    aspect-ratio: 400 / var(--world-height);
    overflow: hidden;
    touch-action: none;
    -webkit-touch-callout: none;
}

@media (min-width: 600px){
    .screen{
        border-radius: 18px;
        box-shadow: 0 14px 40px rgba(0, 0, 0, .4);
    }
}

.game-canvas{
    display: block;
    width: 100%;
    height: 100%;
}

/* ---------- Depth, catch and buttons over the game ---------- */

.hud{
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 12px;
    pointer-events: none;
}

.hud__stats{
    font-weight: bold;
    line-height: 1;
    color: #fff;
    text-shadow: 0 2px 0 rgba(0, 0, 0, .35), 0 0 8px rgba(0, 0, 0, .3);
    font-variant-numeric: tabular-nums;
}

.hud__depth{
    font-size: 30px;
}

.hud__stats small{
    display: block;
    margin-top: 6px;
    font-size: 15px;
}

/* At the dock the depth is 0: the wallet on the panel says what matters. */
.screen:not([data-phase="casting"]):not([data-phase="paused"]) .hud__stats{
    visibility: hidden;
}

.hud__buttons{
    display: flex;
    gap: 8px;
}

.round{
    width: 42px;
    height: 42px;
    font-size: 18px;
    color: #fff;
    background: rgba(8, 36, 70, .45);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
}

.round[hidden]{
    display: none;
}

/* ---------- Dock, pause and catch screens ---------- */

.panel{
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 56px 14px 14px;
    text-align: center;
    animation: fade-in .3s ease-out;
    overflow-y: auto;
}

.panel[hidden]{
    display: none;
}

/* Pause covers the sea; the dock and the catch leave the boat in view below their card. */
.panel--dim{
    justify-content: center;
    padding: 24px;
    background: rgba(5, 20, 40, .82);
}

@keyframes fade-in{
    from{ opacity: 0; }
}

.dock{
    width: min(100%, 372px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 14px;
    background: var(--card);
    border-radius: 22px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
}

.panel__title{
    font-size: clamp(36px, 11cqw, 46px);
    font-weight: bold;
    line-height: 1;
    color: var(--accent);
    text-shadow: 0 3px 0 #b8860b;
}

.panel__text{
    max-width: 320px;
    font-size: 16px;
}

.wallet{
    padding: 4px 16px;
    font-size: 22px;
    font-weight: bold;
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    font-variant-numeric: tabular-nums;
}

.dock__best{
    font-size: 14px;
    color: var(--text-muted);
}

.panel__links{
    max-width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.panel__links .button{
    min-height: 38px;
    padding: 0 14px;
    font-size: 14px;
}

.button{
    min-height: 44px;
    padding: 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: bold 16px var(--font);
    color: var(--text);
    text-decoration: none;
    background: rgba(255, 255, 255, .14);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition: transform .1s;
}

.button:active,
.round:active,
.upgrade__buy:active{
    transform: scale(.94);
}

.button[hidden]{
    display: none;
}

.button:focus-visible,
.round:focus-visible,
.upgrade__buy:focus-visible{
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.button--accent{
    color: var(--accent-text);
    background: var(--accent);
}

.button--big{
    min-height: 54px;
    min-width: 200px;
    font-size: 22px;
}

.button--ranks{
    color: var(--accent-text);
    background: #7fe3ff;
}

/* ---------- Upgrades ---------- */

.upgrades{
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    list-style: none;
}

.upgrade{
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 6px 6px 10px;
    text-align: left;
    border-radius: 14px;
    background: rgba(255, 255, 255, .08);
}

.upgrade__icon{
    font-size: 24px;
}

.upgrade__text{
    flex: 1;
    min-width: 0;
}

.upgrade__name{
    font-size: 14px;
    font-weight: bold;
}

.upgrade__effect{
    font-size: 12px;
    color: var(--text-muted);
}

.upgrade__buy{
    flex-shrink: 0;
    min-width: 84px;
    min-height: 40px;
    padding: 0 10px;
    font: bold 15px var(--font);
    color: var(--accent-text);
    background: var(--accent);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
}

.upgrade__buy:disabled{
    cursor: default;
    color: var(--text-muted);
    background: rgba(255, 255, 255, .1);
}

/* ---------- The catch ---------- */

.result__haul{
    font-size: 48px;
    font-weight: bold;
    line-height: 1;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.result__fish{
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    list-style: none;
}

.result__chip{
    padding: 4px 10px;
    font-size: 13px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
}

.result__chip.is-golden{
    color: var(--accent-text);
    background: var(--accent);
    font-weight: bold;
}

/* A small gold coin, drawn in CSS so it looks the same everywhere (emoji coins differ per phone). */
.coin-icon{
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-right: .3em;
    vertical-align: -.15em;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, #fff3a0 0 30%, #ffd23f 32% 100%);
    box-shadow: inset 0 -.1em 0 #c98b00, 0 0 0 .06em #c98b00;
}

/* ---------- Messages ---------- */

.toast{
    position: absolute;
    left: 50%;
    top: 70px;
    z-index: 3;
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 10px 18px;
    font-weight: bold;
    text-align: center;
    color: var(--accent-text);
    background: var(--accent);
    border-radius: 999px;
    transform: translateX(-50%);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
    pointer-events: none;
}

.toast[hidden]{
    display: none;
}

/* How to play, during a new player's first casts. */
.coach{
    position: absolute;
    left: 50%;
    bottom: 10%;
    z-index: 1;
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 10px 16px;
    font-size: 16px;
    font-weight: bold;
    line-height: 1.35;
    white-space: pre-line;
    text-align: center;
    color: #fff;
    background: rgba(8, 36, 70, .85);
    border: 2px solid var(--accent);
    border-radius: 16px;
    transform: translateX(-50%);
    pointer-events: none;
}

.coach[hidden]{
    display: none;
}

/* ---------- Top 50 ---------- */
.ranks{
    width: min(480px, calc(100% - 24px));
    max-height: min(680px, calc(100dvh - 24px));
    margin: auto;
    padding: 0;
    display: none;
    flex-direction: column;
    color: var(--text);
    background: var(--dialog);
    border: 0;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
    font-family: var(--font);
}

.ranks[open]{
    display: flex;
}

.ranks::backdrop{
    background: rgba(3, 12, 25, .6);
}

.ranks__header{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 10px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.ranks__title{
    font-size: 24px;
    color: var(--accent);
}

.ranks__status{
    margin-top: 2px;
    font-size: 14px;
    color: var(--text-muted);
}

.ranks__close{
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    font-size: 18px;
    color: var(--text);
    background: rgba(255, 255, 255, .1);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.ranks__name{
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.ranks__name.is-asking{
    background: rgba(255, 210, 63, .12);
}

.ranks__name-label{
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: bold;
}

.ranks__name-hint{
    display: none;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--accent);
}

.ranks__name.is-asking .ranks__name-hint{
    display: block;
}

.ranks__name-row{
    display: flex;
    gap: 8px;
}

/* 16px or more, so iPhone does not zoom in when the field gets the focus. */
.ranks__name-input{
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 0 12px;
    font: 16px var(--font);
    color: var(--accent-text);
    background: var(--text);
    border: 0;
    border-radius: 12px;
}

.ranks__name-save{
    min-height: 44px;
    padding: 0 18px;
    font: bold 15px var(--font);
    color: var(--accent-text);
    background: var(--accent);
    border: 0;
    border-radius: 12px;
    cursor: pointer;
}

.ranks__list{
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px 12px 10px;
    list-style: none;
}

.ranks__row{
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    font-size: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.ranks__row.is-you{
    background: rgba(255, 210, 63, .18);
    border-radius: 10px;
}

.ranks__rank{
    flex: 0 0 32px;
    font-weight: bold;
    color: var(--text-muted);
    text-align: center;
}

.ranks__player{
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ranks__score{
    font-weight: bold;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.ranks__you{
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    font-size: 14px;
    font-weight: bold;
    color: #7fe3ff;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, .1);
}

.ranks__you:empty{
    display: none;
}
