/* ==========================================================================
   MODULE 1: CORE DEFAULTS & GLOBAL CSS GRID WRAPPERS
   ========================================================================== */
* {
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

html,
body {
    background: #1e1e1e;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#app-wrapper {
    background-color: #1e1e1e;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: min-content 1fr min-content;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
}

#header {
    background-color: #1e1e1e;
    color: #888888;
    font-size: 1.1rem;
    height: 124px;
    padding-top: 80px;
    position: relative;
    z-index: 10;
    box-shadow: 0 14px 24px rgba(0, 0, 0, 0.4);
    -webkit-box-shadow: 0 14px 24px rgba(0, 0, 0, 0.4);
}

#header h1 {
    font-size: 18px;
    color: #fff;
    text-align: center;
    margin: 0;
}

#body {
    background-color: #121212;
    color: #e0e0e0;
    font-size: 1rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: max-height 0.25s cubic-bezier(0.1, 0.76, 0.55, 0.94);
}

#empty-state-msg p {
    filter: grayscale(1);
}

/* ==========================================================================
   MODULE 2: NAVIGATION FOOTER & CORE ACTION LINKS
   ========================================================================== */
#footer {
    background-color: #1e1e1e;
    color: #888888;
    font-size: 1.1rem;
    text-align: center;
    height: 100px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    position: relative;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
}

#footer a {
    width: 100%;
    max-width: 80px;
    height: 80px;
    line-height: 80px;
    display: inline-block;
    text-decoration: none;
    margin: auto;
    filter: grayscale(100%);
    color: #808080;
    font-size: 24px;
}

/* ==========================================================================
   MODULE 3: DYNAMIC PLAYERS GAMEPLAY RUNTIME INTERFACE
   ========================================================================== */
#players-list {
    padding: 10px;
    margin: 0;
    height: 100%;
}

.player-card {
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 15px;
    margin: 10px;
    background: #1c1c1e;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#players-list .player-card.active-player-row {
    background-color: #2c2c2e !important;
    border: 2px solid #0a84ff !important;
    box-shadow: 0 0 12px rgba(10, 132, 255, 0.3);
    transform: scale(1.01);
}

.active-player-row .fa-dice {
    color: #0a84ff !important;
    animation: activePulse 2s infinite ease-in-out;
    display: inline-block;
}

@keyframes activePulse {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 0px rgba(224, 224, 224, 0)) !important;
    }
    50% {
        transform: scale(1.15) rotate(15deg);
        filter: drop-shadow(0 0 5px rgba(224, 224, 224, 0.45)) !important;
    }
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 0px rgba(224, 224, 224, 0)) !important;
    }
}

/* ==========================================================================
   MODULE 4: BASE ARCHITECTURE FOR OVERLAY MODAL SHEETS
   ========================================================================== */
#calc-overlay,
#add-player-overlay,
#reset-overlay,
#leaderboard-overlay,
#settings-overlay,
#manual-score-overlay,
#help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
    backdrop-filter: blur(2px) saturate(120%);
    -webkit-backdrop-filter: blur(2px) saturate(120%);
    background: rgba(0, 0, 0, 0.85);
}

#calc-overlay          {
    z-index: 9999;
    background-color: transparent !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#add-player-overlay    { z-index: 10000; }
#reset-overlay         { z-index: 10001; }
#leaderboard-overlay   { z-index: 10002; }
#settings-overlay      { z-index: 10003; }
#help-overlay          { z-index: 10003; }
#manual-score-overlay  { z-index: 10004; }

#calc-container,
#add-player-container,
#reset-container,
#leaderboard-container,
#settings-container,
#manual-score-container,
#help-container {
    background-color: #1c1c1e;
    border-top: 1px solid #2c2c2e;
    border-radius: 12px 12px 0 0;
    width: 100%;
    max-width: 100%;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom)) 16px;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.25s cubic-bezier(0.1, 0.76, 0.55, 0.94) forwards;
    position: absolute;
    pointer-events: auto;
}

/* ==========================================================================
   MODULE 5: OVERLAY CORE HEADERS & INTERACTION BUTTONS
   ========================================================================== */
#calc-header,
#add-player-header,
#reset-header,
#leaderboard-header,
#settings-header,
#manual-score-header,
#help-header {
    display: flex;
    justify-content: space-between;
    align-items: center !important; /* Forces aligned execution lines */
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #2c2c2e;
    box-sizing: border-box;
    width: 100%;
}

#calc-player-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

#calc-player-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff;
}

#calc-stats-row {
    display: flex;
    gap: 6px;
    font-size: 0.85rem;
    color: #8e8e93;
}

#calc-close,
#reset-close,
#leaderboard-close,
#settings-close,
#manual-score-close,
#help-close {
    background: none !important;
    border: none !important;
    color: #0a84ff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    flex-shrink: 0;
}

#add-player-close {
    background: none !important;
    border: none !important;
    color: #ff453a;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    flex-shrink: 0;
}

#leaderboard-ranks-list {
    padding-left: 0;
}

/* ==========================================================================
   MODULE 6: GAMEPLAY OVERLAY ENGINE CALCULATOR GRID
   ========================================================================== */
#calc-score-view {
    background-color: #000000;
    border-radius: 10px;
    padding: 12px;
    text-align: right;
    margin-bottom: 16px;
}

#calc-temp-score {
    display: block;
    font-size: 2.8rem;
    font-weight: 400;
    color: #ffffff;
    line-height: 1;
}

#calc-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #8e8e93;
    letter-spacing: 0.5px;
    margin-top: 4px;
    display: block;
}

#calc-grid {
    display: grid;
    gap: 10px;
}

.calc-bottom-row {
    display: grid;
    gap: 10px;
}

.calc-btn {
    border: none;
    border-radius: 10px;
    padding: 22px 10px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.score-add {
    background-color: #2c2c2e;
    color: #ffffff;
}

.score-add:active {
    background-color: #3a3a3c;
}

.score-clear {
    background: none !important;
    border: none !important;
    color: #888;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.score-clear:active {
    opacity: 1;
    transform: scale(0.92);
}

#calc-bust {
    background-color: #ff453a;
    color: #fff;
}

#calc-bust:active {
    background-color: #ff3b30;
}

#calc-bank {
    background-color: #30d158;
    color: #fff;
}

#calc-bank:active {
    background-color: #34c759;
}

#add-player-form,
#reset-form,
#settings-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#new-player-name,
#manual-score-input {
    background-color: #000000;
    border: 1px solid #2c2c2e;
    border-radius: 10px;
    color: #ffffff;
    padding: 16px;
    font-size: 1.1rem;
    outline: none;
    width: 100%;
}

#new-player-name::placeholder {
    color: #8e8e93;
}

#add-player-submit,
.reset-action-btn {
    background-color: #0a84ff;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    text-align: center;
}

#add-player-submit:active,
.reset-action-btn:not(.action-danger):active {
    background-color: #007aff;
}

#reset-warning-msg {
    font-size: 0.95rem;
    color: #aeaeb2;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.action-danger {
    background-color: #ff453a !important;
}

.action-danger:active {
    background-color: #ff3b30 !important;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
