* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

:root {
    --bg-color: #080808;
    --ui-bg: #121212;
    --text-color: #ffffff;
    --modal-bg: #121212;
    --accent: #4a90e2;
    --panel-bg: #1e1e1e;
}

body.light-mode {
    --bg-color: #f0f2f5;
    --ui-bg: #ffffff;
    --text-color: #333333;
    --modal-bg: #ffffff;
    --panel-bg: #f8f9fa;
}

body {
    background-color: var(--bg-color);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-color);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s, color 0.3s;
}

#app-container {
    width: 100%;
    height: 100%;
    max-width: 500px;
    background-color: var(--ui-bg);
    position: relative;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background-color 0.3s;
}

#gameCanvas {
    flex: 1;
    width: 100%;
    height: 100%;
    display: block;
}

/* UI LAYER */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 5;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0s 0.3s;
}

#ui-layer.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s, visibility 0s 0s;
}

#hud {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 80px;
    pointer-events: none;
    background: transparent;
}

.hud-left {
    display: flex;
    gap: 10px;
    align-items: center;
    pointer-events: auto;
}

.hud-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.hud-right {
    display: flex;
    gap: 8px;
    pointer-events: auto;
}

/* RECTANGULAR HUD BUTTONS */
.hud-btn {
    background: rgba(30, 30, 30, 0.8);
    border: 1px solid #444;
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    pointer-events: auto;
}

body.light-mode .hud-btn {
    background: #fff;
    border-color: #ddd;
    color: #555;
}

.hud-btn:active {
    transform: scale(0.95);
}

.badge-inner {
    background: var(--accent);
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 8px;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

.icon-btn {
    font-size: 24px;
    cursor: pointer;
    color: #888;
    padding: 5px;
    pointer-events: auto;
}

.icon-btn:hover {
    color: var(--text-color);
}

.timer-box {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-color);
    font-feature-settings: "tnum";
}

.level-badge {
    font-size: 12px;
    background: #333;
    padding: 4px 10px;
    border-radius: 12px;
    color: #fff;
    font-weight: bold;
}

#tutorial-msg {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.3s;
    text-align: center;
    white-space: nowrap;
}

#controls {
    padding: 20px;
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    pointer-events: none;
    margin-bottom: 20px;
}

.action-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--ui-bg);
    border: 2px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    font-size: 24px;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.1s;
}

body:not(.light-mode) .action-btn {
    border-color: #333;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.action-btn:active {
    transform: scale(0.95);
}

/* SCREENS */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0s 0.3s;
    padding: 20px;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.3s, visibility 0s 0s;
}

h1 {
    font-size: 42px;
    line-height: 1.1;
    margin-bottom: 30px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 900;
    text-align: center;
}

h2 {
    font-size: 28px;
    margin-bottom: 20px;
    color: var(--text-color);
    font-weight: 800;
    text-align: center;
}

.stats-panel {
    background: var(--panel-bg);
    width: 100%;
    max-width: 400px;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
    font-size: 16px;
    color: var(--text-color);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-val {
    font-weight: bold;
}

.victory-card {
    background: var(--panel-bg);
    width: 100%;
    max-width: 350px;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.victory-icon {
    font-size: 48px;
    margin-bottom: 10px;
    display: block;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
    font-size: 16px;
}

.summary-row:last-child {
    border-bottom: none;
}

.win-buttons {
    width: 100%;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    background: var(--ui-bg);
    color: var(--text-color);
    border: 2px solid #333;
    padding: 16px 0;
    margin: 8px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    width: 260px;
    text-align: center;
    transition: all 0.2s;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}

body.light-mode .btn {
    border-color: #ddd;
    box-shadow: 0 4px 0 #ddd;
}

.btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

.btn-menu {
    border-left: 8px solid var(--accent);
}

/* RESTORED BIG PLAY BUTTON SIZE */
.btn-primary {
    background: var(--accent) !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 6px 0 #2d6da6 !important;
    width: 100%;
    margin: 0;
    padding: 20px 0;
    font-size: 22px;
    /* Bigger padding */
}

.btn-secondary {
    background: transparent !important;
    color: var(--text-color) !important;
    border: 2px solid #555 !important;
    box-shadow: none !important;
    width: 100%;
    margin: 0;
}

.btn-back {
    border: none;
    color: #888;
    margin-top: 10px;
    box-shadow: none;
}

.btn.easy {
    border-left: 8px solid #4CAF50;
}

.btn.med {
    border-left: 8px solid #FFC107;
}

.btn.hard {
    border-left: 8px solid #FF5722;
}

/* MODALS */
.modal-popup {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-popup.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.popup-content {
    background: var(--panel-bg);
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    max-width: 300px;
}

.popup-content p {
    color: #888;
    margin: 10px 0 20px;
}

.popup-btns {
    display: flex;
    gap: 10px;
}

.popup-btn {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    background: #ddd;
    color: #000;
    border: none;
}

.popup-btn.danger {
    background: #e53935;
    color: white;
}
/* RESUME BUTTON SPECIFIC STYLE */
#btn-resume {
    background: #4CAF50 !important;
    /* Green */
    color: white !important;
    border: none !important;
    box-shadow: 0 6px 0 #388E3C !important;
    /* Darker Green Shadow */
    width: 100%;
    margin: 0 0 10px 0;
    /* Add some space below it */
}

#btn-resume:active {
    transform: translateY(4px);
    box-shadow: none !important;
}