/* =========================================
   GAMES.CSS - Consolidated Game Styles
   ========================================= */

/* === SHARED STYLES === */

/* Wrappers */
.plankle-wrapper, 
.trivia-wrapper,
.plank-wrapper,
.memory-wrapper,
.dig-wrapper,
.cannon-wrapper {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
    padding: 10px;
}

/* Memory wrapper is slightly wider in original, overriding max-width */
.memory-wrapper {
    max-width: 520px;
}

/* Shared Stats Bar (Trivia, Memory, Dig, Cannon) */
.stats-bar {
    display: flex;
    justify-content: space-around;
    font-size: 1.2rem;
    color: var(--neon-pink, #ff007f);
    margin: 15px 0; /* Normalized */
}

/* Shared Message Box */
#message {
    font-size: 1.2rem;
    min-height: 1.5em;
    margin: 10px 0;
    color: var(--neon-pink, #ff007f);
    font-weight: bold;
}

/* Base Grid Container (Memory, Dig) */
.grid {
    display: grid;
    margin: 20px auto;
}

/* Shared Ship Image (Plank, Cannon) */
.ship-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Shared Sea Background (Plank, Cannon) */
.sea-bg {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: url('/images/sea.gif') repeat-x bottom left;
    background-size: auto 100%; 
    z-index: 1;
}

/* Shared Leaderboard & Score Modal */
.leaderboard-box {
    background: rgba(39, 1, 72, 0.6);
    border: 2px solid var(--neon-pink, #ff007f);
    border-radius: 8px;
    padding: 15px;
    margin: 20px auto;
    max-width: 380px;
}

.leaderboard-box h3 {
    margin: 0 0 10px 0;
    color: #00FF66;
    font-size: 1.3rem;
}

.lb-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

.lb-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    border-bottom: 1px solid #444;
    font-size: 1.2rem; 
}

.lb-item:last-child {
    border-bottom: none;
}

.lb-rank {
    font-weight: bold;
    color: var(--neon-pink, #ff007f);
}

.score-modal {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 15px;
}

.score-input {
    padding: 8px 12px;
    font-size: 1.2rem;
    border-radius: 4px;
    border: 1px solid #555;
    background: #2a2a2e;
    color: #fff;
    max-width: 180px;
}

.button-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 20px;
}


/* === PLANKLE SPECIFIC STYLES === */

.board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 6px;
    margin: 15px auto;
    width: 320px;
    height: 380px;
}

.row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.tile {
    width: 100%;
    height: 100%;
    border: 2px solid #555;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    text-transform: uppercase;
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    user-select: none;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.tile.active-tile {
    border-color: #00FF66 !important; 
    box-shadow: 0 0 10px rgba(0, 255, 102, 0.6);
}

.tile[data-state="correct"], .key[data-state="correct"] {
    background-color: #2e7d32 !important; 
    border-color: #2e7d32 !important;
    color: #fff;
}
.tile[data-state="present"], .key[data-state="present"] {
    background-color: #b78103 !important; 
    border-color: #b78103 !important;
    color: #fff;
}
.tile[data-state="absent"], .key[data-state="absent"] {
    background-color: #3a3a3c !important; 
    border-color: #3a3a3c !important;
    color: #888;
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 20px auto 10px auto;
    width: 100%;
    max-width: 500px;
    padding: 0 4px;
    box-sizing: border-box;
}

.kb-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

.key {
    font-family: inherit;
    font-size: 1.25rem;
    height: 58px;
    flex: 1;
    min-width: 0;
    background: #2a2a2e;
    color: #fff;
    border: 1px solid #444;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, opacity 0.1s ease;
}

.key.wide-key {
    flex: 1.5;
    font-size: 0.95rem;
}

.key:active {
    opacity: 0.6;
    transform: scale(0.96);
}


/* === TRIVIA SPECIFIC STYLES === */

.question-box { 
    font-size: 1.5rem; 
    line-height: 1.5;
    margin: 20px 0; 
    color: #fff;
    background: rgba(39, 1, 72, 0.4);
    border: 2px solid #555;
    border-radius: 8px;
    padding: 15px;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.options { 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    margin-bottom: 20px; 
}

.opt-btn { 
    background: #2a2a2e; 
    color: #fff; 
    border: 1px solid #444; 
    padding: 14px; 
    font-size: 1.5rem;
    border-radius: 6px; 
    cursor: pointer; 
    transition: background 0.15s, border-color 0.15s, transform 0.1s; 
}

.opt-btn:hover:not(:disabled) { 
    background: #3a3a3e; 
    border-color: #666;
}

.opt-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.opt-btn.correct {
    background: #2e7d32 !important;
    border-color: #2e7d32 !important;
    color: #fff;
}

.opt-btn.wrong {
    background: #7f1d1d !important;
    border-color: #ef4444 !important;
    color: #fff;
}

.opt-btn:disabled {
    cursor: not-allowed;
    opacity: 0.85;
}

#result {
    font-size: 1.3rem; 
    font-weight: bold; 
    color: #00FF66; 
    margin: 15px 0;
    min-height: 1.5em;
}


/* === PLANK SPECIFIC STYLES === */

.plank-stage {
    position: relative;
    width: 100%;
    height: 200px;
    background: #030a16;
    border: 3.5px solid #ff007f; 
    border-radius: 12px;
    margin: 20px 0;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(255, 0, 127, 0.45);
}

.sea-foreground {
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 28px;
    background: linear-gradient(to top, rgba(0, 100, 255, 0.35), rgba(0, 50, 200, 0));
    z-index: 6; 
    pointer-events: none;
}

.ship-deck {
    position: absolute;
    left: -15px;
    bottom: 25px;
    width: 135px;
    height: 125px;
    z-index: 3;
}

.plank-beam {
    position: absolute;
    left: 80px;
    bottom: 55px;
    width: 250px;
    height: 12px;
    background: #5c3b1c;
    border: 2px solid #1a0f05;
    border-radius: 2px;
    box-shadow: 0 5px 8px rgba(0, 0, 0, 0.7);
    z-index: 4;
}

.pirate-runner {
    position: absolute;
    bottom: 64px; 
    left: 85px;
    height: 55px; 
    width: auto;
    z-index: 5;
    transition: left 0.4s ease-out, transform 0.5s ease, opacity 0.5s ease;
    filter: drop-shadow(0px 3px 5px rgba(0,0,0,0.7)); 
}

.pirate-runner.splash {
    transform: translateY(60px) rotate(90deg) scale(0.6);
    opacity: 0;
}

.kraken-tentacle {
    position: absolute;
    bottom: -5px; 
    width: auto;
    z-index: 2; 
    transform-origin: bottom center;
    animation: tentacleWiggle 3.2s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 8px rgba(45, 0, 77, 0.8)) drop-shadow(0 0 15px rgba(0, 0, 0, 0.9));
}

.kraken-tentacle.t1 { 
    left: 170px; 
    height: 105px;  
    z-index: 2; 
    animation: tentacleWiggleCenter 3.2s ease-in-out infinite alternate;
}

.kraken-tentacle.t2 { 
    left: 230px; 
    height: 135px; 
    z-index: 5; 
    animation: tentacleReachShip 3.5s ease-in-out infinite alternate;
}

.kraken-tentacle.t3 { 
    left: 310px; 
    height: 115px; 
    z-index: 2; 
    animation-delay: 0.4s;
}

.kraken-tentacle.t4 { 
    left: 390px; 
    height: 140px; 
    z-index: 5; 
    animation-delay: 1s;
}

@keyframes tentacleWiggleCenter {
    0% { transform: translateY(8px) rotate(-3deg); }
    100% { transform: translateY(-2px) rotate(5deg); }
}

@keyframes tentacleReachShip {
    0% { transform: scaleX(-1) rotate(-22deg) translateY(4px); }
    100% { transform: scaleX(-1) rotate(-30deg) translateY(-6px); }
}

@keyframes tentacleWiggle {
    0% { transform: translateY(8px) rotate(-4deg); }
    50% { transform: translateY(0px) rotate(3deg); }
    100% { transform: translateY(6px) rotate(-2deg); }
}

.word-display {
    font-size: 2.2rem;
    letter-spacing: 8px;
    font-weight: bold;
    color: var(--neon-pink, #ff007f);
    margin: 15px 0;
}

/* Plank Keyboard Override */
.plank-wrapper .keyboard {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row; 
    gap: 6px;
    justify-content: center;
    max-width: 460px;
    margin: 0 auto;
}

.letter-btn {
    width: 40px;
    height: 44px;
    font-size: 1.3rem;
    background: #2a2a2e;
    color: #fff;
    border: 1px solid #444;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.letter-btn:hover:not(:disabled) {
    background: #3a3a3e;
    border-color: #666;
}

.letter-btn.correct {
    background: #2e7d32 !important;
    border-color: #2e7d32 !important;
}

.letter-btn.wrong {
    background: #3a3a3c !important;
    border-color: #3a3a3c !important;
    color: #777;
}

.letter-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}


/* === MEMORY SPECIFIC STYLES === */

.memory-wrapper .grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 400px;
}

.card {
    aspect-ratio: 1;
    background: #2a2a2e;
    border: 2px solid #555;
    border-radius: 8px;
    font-size: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: transform 0.3s, background-color 0.3s;
}

.card.flipped {
    background: rgba(39, 1, 72, 0.9);
    border-color: var(--neon-pink, #ff007f);
    transform: rotateY(180deg);
}

.card.matched {
    background: #2e7d32;
    border-color: #2e7d32;
    cursor: default;
}


/* === DIG SPECIFIC STYLES === */

.dig-wrapper .grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    width: 320px;
    height: 320px;
}

.cell {
    background: #3a2e2b;
    border: 2px solid #6e544f;
    border-radius: 6px;
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.cell:hover:not(.dug):not(.bomb) {
    background: #4a3c38;
    border-color: #8e6c65;
    transform: scale(1.04);
}

.cell.dug {
    background: #1a1514;
    border-color: #3a2e2b;
    color: #00FF66;
    cursor: default;
}

/* Number clue colors */
.cell.count-1 { color: #3b82f6; }
.cell.count-2 { color: #22c55e; }
.cell.count-3 { color: #ef4444; }
.cell.count-4 { color: #a855f7; }

.cell.bomb {
    background: #7f1d1d;
    border-color: #ef4444;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}


/* === CANNON SPECIFIC STYLES === */

.sea-arena {
    position: relative;
    width: 100%;
    height: 200px;
    background: #030a16;
    border: 3.5px solid var(--neon-pink, #ff007f);
    border-radius: 12px;
    overflow: hidden;
    margin: 20px 0;
    box-shadow: 0 0 20px rgba(255, 0, 127, 0.45);
}

.cannon-wrapper .sea-bg {
    filter: brightness(0.7) contrast(1.1);
}

.enemy-ship {
    position: absolute;
    top: 30px;
    width: 80px;
    height: 80px;
    z-index: 3;
    user-select: none;
    transition: transform 0.1s linear;
}

.crosshair {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    background: rgba(255, 0, 127, 0.8);
    transform: translateX(-50%);
    box-shadow: 0 0 10px var(--neon-pink, #ff007f);
    z-index: 4;
}

.crosshair::before {
    content: '🎯';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.8rem;
    opacity: 0.8;
}

.hit-effect {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 3rem;
    z-index: 5;
    animation: popFade 0.6s ease-out forwards;
}

@keyframes popFade {
    0% { transform: translate(-50%, 0) scale(0.5); opacity: 1; }
    50% { transform: translate(-50%, -15px) scale(1.3); opacity: 1; }
    100% { transform: translate(-50%, -30px) scale(1); opacity: 0; }
}

.fire-button-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 15px auto;
}

.fire-btn {
    font-size: 1.3rem;
    padding: 14px 32px;
    cursor: pointer;
    box-shadow: 0 0 12px rgba(255, 0, 127, 0.4);
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.fire-btn:active {
    transform: scale(0.96);
}