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

body {
    background: #1a1a2e;
    color: #eee;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#app {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ============ Screen Overlay ============ */
#screen-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.screen-box {
    background: #16213e;
    border: 2px solid #0f3460;
    border-radius: 10px;
    padding: 32px 48px;
    text-align: center;
}

.game-title {
    font-size: 48px;
    color: #e94560;
    margin-bottom: 6px;
    text-shadow: 0 0 12px rgba(233, 69, 96, 0.5);
}

.game-subtitle {
    font-size: 18px;
    color: #999;
    margin-bottom: 20px;
}

.screen-btn {
    background: #e94560;
    color: #fff;
    border: none;
    padding: 10px 28px;
    font-size: 16px;
    border-radius: 6px;
    cursor: pointer;
    margin: 6px;
    transition: background 0.2s;
}
.screen-btn:hover {
    background: #c73e54;
}

.victory h1 { color: #2ecc71; }
.defeat h1 { color: #e74c3c; }

/* Rules screen */
.rules-box {
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    text-align: left;
    padding: 32px 40px;
}
.rules-section {
    margin-bottom: 14px;
}
.rules-section h3 {
    color: #e94560;
    font-size: 15px;
    margin-bottom: 4px;
}
.rules-section p {
    color: #bbb;
    line-height: 1.6;
    font-size: 14px;
}

/* ============ Level Select ============ */
#level-select {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 90;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.screen-title {
    font-size: 32px;
    color: #e94560;
    margin-bottom: 20px;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(2, 280px);
    gap: 12px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 8px;
}

.level-card {
    background: #16213e;
    border: 2px solid #0f3460;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.1s;
}
.level-card:hover {
    border-color: #e94560;
    transform: translateY(-2px);
}
.level-card h2 {
    font-size: 18px;
    color: #eee;
    margin-bottom: 4px;
}
.level-card p {
    font-size: 13px;
    color: #999;
}
.level-locked {
    opacity: 0.4;
    cursor: not-allowed;
}
.level-locked:hover {
    border-color: #0f3460;
    transform: none;
}
.level-complete {
    color: #2ecc71;
    font-size: 12px;
    font-weight: bold;
}
.level-locked-text {
    color: #e74c3c;
    font-size: 12px;
    font-weight: bold;
}
.level-chapter {
    font-size: 10px;
    text-transform: uppercase;
    color: #e94560;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

/* ============ Game Area ============ */
#game-area {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Top bar */
#top-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 16px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    min-height: 40px;
}

#turn-indicator {
    font-weight: bold;
    font-size: 18px;
    color: #e94560;
}

#phase-display {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 14px;
    background: #0f3460;
}
.phase-draw { background: #2980b9 !important; }
.phase-action { background: #27ae60 !important; }
.phase-enemy { background: #c0392b !important; }
.phase-targeting { background: #e67e22 !important; }
.phase-replace { background: #8e44ad !important; }

#objective-display {
    flex: 1;
    font-size: 13px;
    color: #ccc;
}

#btn-rules {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #0f3460;
    color: #ccc;
    border: 1px solid #2c3e6e;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}
#btn-rules:hover {
    background: #1a4a8a;
    color: #fff;
}

#btn-end-turn {
    background: #e94560;
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
#btn-end-turn:hover {
    background: #c73e54;
}

/* Main content */
#main-content {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* Sidebar */
#sidebar {
    width: 220px;
    background: #0f1629;
    border-right: 1px solid #0f3460;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 2;
}

#unit-info {
    padding: 12px;
    border-bottom: 1px solid #0f3460;
    min-height: 100px;
}

.unit-info-empty {
    color: #666;
    font-size: 14px;
    text-align: center;
    padding-top: 12px;
}

.unit-info-header {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 8px;
}

.unit-stats {
    font-size: 14px;
    line-height: 1.8;
}

.unit-stats div {
    color: #ccc;
}

.unit-buffs {
    color: #f1c40f !important;
    font-size: 12px;
}

.unit-enraged {
    color: #e74c3c !important;
    font-weight: bold;
}

/* Canvas container */
#game-container {
    flex: 1;
    position: relative;
    background: #111827;
    overflow: hidden;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
}

/* Sidebar cards section */
#sidebar-cards {
    border-top: 1px solid #0f3460;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    max-height: 50%;
}

#deck-info {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    padding: 0 4px 2px;
}

#card-hand {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 2px;
}

#card-hint {
    font-size: 11px;
    color: #555;
    padding: 0 4px;
}

/* Card */
.card {
    position: relative;
    background: #1e2a4a;
    border: 2px solid var(--card-color, #555);
    border-radius: 6px;
    padding: 10px 10px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    z-index: 10;
}
.card-selected {
    transform: translateX(4px) !important;
    box-shadow: 0 0 16px var(--card-color, #ff0) !important;
    border-color: #ff0 !important;
    z-index: 10;
}
.card-disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.card-disabled:hover {
    transform: none;
    box-shadow: none;
}

.card-icon {
    font-size: 28px;
    line-height: 1;
    flex-shrink: 0;
}

.card-icon-img {
    width: 28px;
    height: 28px;
}

.unit-icon-img {
    width: 20px;
    height: 20px;
    vertical-align: middle;
}

.card-marked {
    opacity: 0.5;
    border-color: #e74c3c !important;
    border-style: dashed !important;
}

.card-header {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
    text-align: left;
}

/* Tooltip: hidden by default, shown on hover/selected */
.card-details {
    display: none;
    position: absolute;
    left: calc(100% + 10px);
    bottom: 0;
    transform: none;
    background: #1a1a2e;
    border: 2px solid var(--card-color, #555);
    border-radius: 8px;
    padding: 14px 16px;
    min-width: 240px;
    max-width: 320px;
    pointer-events: none;
    z-index: 20;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    text-align: left;
}
.card-details::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 100%;
    transform: translateY(-50%);
    border: 8px solid transparent;
    border-right-color: var(--card-color, #555);
}
.card:hover .card-details,
.card-selected .card-details {
    display: block;
}

.card-type {
    font-size: 15px;
    color: var(--card-color, #888);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: bold;
    margin-bottom: 6px;
}

.card-desc {
    font-size: 16px;
    color: #aaa;
    line-height: 1.6;
}

/* ============ Story Panel ============ */
#story-panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
}

#story-entries {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.story-entry {
    font-size: 13px;
    line-height: 1.5;
    color: #c8b88a;
    padding: 6px 8px;
    border-left: 2px solid #4a3d28;
    animation: storyFadeIn 0.5s ease-out;
}

.story-entry.story-major {
    color: #e8d8a8;
    font-style: italic;
    border-left-color: #e94560;
    font-size: 14px;
}

.story-entry.story-combat {
    color: #888;
    font-size: 12px;
    border-left-color: #333;
}

@keyframes storyFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============ Briefing Screen ============ */
.briefing .briefing-chapter {
    font-size: 12px;
    text-transform: uppercase;
    color: #e94560;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.briefing .briefing-title {
    font-size: 36px;
    color: #e8d8a8;
    margin-bottom: 16px;
    text-shadow: 0 0 12px rgba(232, 216, 168, 0.3);
}

.briefing .briefing-text {
    text-align: left;
    max-width: 500px;
    margin: 0 auto 20px;
}

.briefing .briefing-text p {
    font-size: 14px;
    color: #c8b88a;
    line-height: 1.7;
    margin-bottom: 10px;
}

/* ============ Victory/Defeat Story Text ============ */
.victory-text, .defeat-text {
    text-align: left;
    max-width: 500px;
    margin: 0 auto 20px;
}

.victory-text p, .defeat-text p {
    font-size: 14px;
    color: #c8b88a;
    line-height: 1.7;
    margin-bottom: 8px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #0a0f1e;
}
::-webkit-scrollbar-thumb {
    background: #2c3e6e;
    border-radius: 3px;
}
