/* ============================================================
   SINKRAZY - single stylesheet for all pages (per TODO.txt)
   English-only, hungarian-notation IDs/classes where relevant.
   ============================================================ */

:root {
    --sColorSea:        #0d3b66;
    --sColorSeaLight:   #1d5a92;
    --sColorGrid:       #0a2f52;
    --sColorMiss:       #9fb8cc;
    --sColorHit:        #e63946;
    --sColorSunk:       #7a0d16;
    --sColorShip:       #52616b;
    --sColorParachute:  #f4a261;
    --sColorPlane:      #8ecae6;
    --sColorText:       #e9f1f7;
    --sColorPanel:      #11263d;
    --sColorAccent:     #ffd166;
    --sColorOk:         #2a9d8f;
    --nCellSize:        34px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    background: radial-gradient(circle at 50% 0%, #15314f 0%, #081a2e 100%) no-repeat;
    background-color: #081a2e;
    color: var(--sColorText);
    min-height: 100vh;
}

header.oTopBar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    background: var(--sColorPanel);
    border-bottom: 2px solid var(--sColorAccent);
}

header.oTopBar .oLogo { display: inline-flex; line-height: 0; }
header.oTopBar .oLogo img {
    height: 56px;
    width: auto;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.4));
}

.oStats { font-size: 14px; }
.oStats b { color: var(--sColorAccent); }

main.oMain {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px;
}

.oMessage {
    min-height: 24px;
    text-align: center;
    font-size: 16px;
    margin: 10px 0;
    color: var(--sColorAccent);
}

.oBoards {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    justify-content: center;
}

.oBoardWrap { text-align: center; }
.oBoardWrap h2 { font-size: 15px; margin: 6px 0; text-transform: uppercase; letter-spacing: 1px; }

/* coordinate labels around the grid */
.oBoardArea {
    display: inline-grid;
    grid-template-columns: 18px auto;
    grid-template-rows: 18px auto;
}
.oCorner { width: 18px; height: 18px; }
.oColLabels { display: flex; }
.oColLabels span {
    width: var(--nCellSize); text-align: center;
    font-size: 11px; color: #8fb0cc; line-height: 18px;
}
.oRowLabels { display: flex; flex-direction: column; }
.oRowLabels span {
    height: var(--nCellSize); width: 18px;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; color: #8fb0cc;
}

/* fleet status */
.oFleet {
    display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
    margin: 10px auto 0; max-width: calc(10 * var(--nCellSize) + 18px);
}
.oFleetItem {
    font-size: 11px; border: 1px solid #2a4c6b; border-radius: 4px;
    padding: 3px 7px; display: inline-flex; gap: 6px; align-items: center;
}
.oFleetItem.oDead { opacity: .5; text-decoration: line-through; border-color: var(--sColorSunk); }
.oPips { display: inline-flex; gap: 2px; }
.oPip { width: 6px; height: 6px; border-radius: 50%; background: #3a5f80; }
.oPip.oHitPip { background: var(--sColorHit); }

.oGrid {
    display: grid;
    gap: 0;
    background: var(--sColorGrid);
    padding: 0;
    border: 2px solid var(--sColorGrid);
    border-radius: 4px;
    user-select: none;
    position: relative;        /* anchor for the sprite overlay */
}

.oCell {
    width: var(--nCellSize);
    height: var(--nCellSize);
    background: var(--sColorSea);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: default;
    position: relative;
    transition: background .12s;
}

/* sprite overlay layer: one div per piece / mark, positioned in px */
.oSpriteLayer {
    position: absolute;
    left: 2px; top: 2px;       /* inside the grid border */
    pointer-events: none;
}
.oSprite {
    position: absolute;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-position: center;
}
.oSprite.oSprShip  { opacity: .95; }
.oSprite.oSprChute { opacity: 1; }
.oSprite.oSprPlane { opacity: 1; }
.oSprite.oSprHit   { opacity: 1; }
.oSprite.oSprMiss  { opacity: .8; }
.oSprite.oSprSunkTint { opacity: .5; filter: saturate(.3) brightness(.7); }

.oGridEnemy .oCell { cursor: crosshair; }
.oGridEnemy .oCell:hover { background: var(--sColorSeaLight); }

.oCell.oMiss   { background: #15415f; }
.oCell.oHit    { background: #5a1f2a; }
.oCell.oSunk   { background: var(--sColorSunk); }
.oCell.oAimed  { outline: 2px solid var(--sColorAccent); outline-offset: -2px; z-index: 3; }

.oCell.oPreviewOk  { background: var(--sColorOk); }
.oCell.oPreviewBad { background: var(--sColorHit); }

.oPanel {
    background: var(--sColorPanel);
    border: 1px solid #244763;
    border-radius: 6px;
    padding: 14px;
    margin: 14px auto;
    max-width: 640px;
}

.oPanel h3 { margin: 0 0 10px; color: var(--sColorAccent); font-size: 15px; }

.oBtn {
    background: var(--sColorAccent);
    color: #1a1a1a;
    border: none;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
    margin: 4px;
}
.oBtn:hover  { filter: brightness(1.08); }
.oBtn:disabled { opacity: .45; cursor: not-allowed; }
.oBtn.oBtnGhost { background: transparent; color: var(--sColorText); border: 1px solid #3a5f80; }

.oPieceList { display: flex; flex-wrap: wrap; gap: 8px; }
.oPieceChip {
    border: 1px solid #3a5f80;
    border-radius: 5px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
}
.oPieceChip.oSelected { border-color: var(--sColorAccent); background: #1c3a58; }
.oPieceChip.oPlaced   { opacity: .4; cursor: default; }

.oLegend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; justify-content: center; margin-top: 10px; }
.oLegend span { display: inline-flex; align-items: center; gap: 5px; }
.oSwatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }

/* juice: hit/miss pop, board shake */
@keyframes kPop { 0%{transform:scale(.2);opacity:0} 55%{transform:scale(1.3)} 100%{transform:scale(1);opacity:1} }
.oSprite.oPop { animation: kPop .35s ease-out; }
@keyframes kShake { 0%,100%{transform:translate(0,0)} 20%{transform:translate(-5px,2px)} 40%{transform:translate(5px,-2px)} 60%{transform:translate(-3px,1px)} 80%{transform:translate(3px,-1px)} }
.oShake { animation: kShake .4s; }

/* end-of-game overlay */
.oOverlay {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(5,15,28,.82);
    display: flex; align-items: center; justify-content: center;
    animation: kFade .25s ease-out;
}
.oOverlay[hidden] { display: none; }
@keyframes kFade { from{opacity:0} to{opacity:1} }
.oOverlayCard {
    background: var(--sColorPanel); border: 2px solid var(--sColorAccent);
    border-radius: 14px; padding: 30px 40px; text-align: center;
    box-shadow: 0 12px 48px rgba(0,0,0,.55); max-width: 90vw;
}
.oResult { font-size: 36px; font-weight: 800; letter-spacing: 3px; color: var(--sColorAccent); }
.oResult.oLose { color: var(--sColorHit); }
.oResultSub { margin: 12px 0 20px; font-size: 15px; line-height: 1.5; }

footer.oFoot { text-align: center; font-size: 12px; opacity: .6; padding: 20px; }

@media (max-width: 760px) {
    :root { --nCellSize: 28px; }
    .oBoards { gap: 14px; }
}
