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

:root {
    --liberal-color: #2196F3;
    --liberal-dark: #1565C0;
    --fascist-color: #f44336;
    --fascist-dark: #c62828;
    --hitler-color: #b71c1c;
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --text-primary: #eee;
    --text-secondary: #aaa;
    --success: #4caf50;
    --warning: #ff9800;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    font-size: 14px;
}

html {
    height: -webkit-fill-available;
}

#app {
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

.screen {
    display: none;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    padding: 15px;
    padding-top: env(safe-area-inset-top, 15px);
    padding-bottom: env(safe-area-inset-bottom, 15px);
}

.screen.active {
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Setup Screen */
#setup-screen {
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 20px;
}

#setup-screen h1 {
    font-size: 1.8rem;
    color: var(--fascist-color);
    text-transform: uppercase;
    letter-spacing: 2px;
}

#setup-screen h2 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: -15px;
}

.player-setup {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 12px;
    width: 100%;
    max-width: 350px;
}

.player-setup h3 {
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#player-inputs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.player-input {
    padding: 12px 15px;
    font-size: 1rem;
    border: 2px solid var(--bg-card);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.player-input:focus {
    border-color: var(--liberal-color);
}

.player-count-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

#player-count {
    font-size: 1rem;
    font-weight: bold;
    min-width: 80px;
    text-align: center;
}

.role-distribution {
    padding: 10px;
    background: var(--bg-card);
    border-radius: 8px;
}

#role-info {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Buttons */
.btn-primary {
    padding: 14px 30px;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--fascist-color), var(--fascist-dark));
    color: white;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary.liberal {
    background: linear-gradient(135deg, var(--liberal-color), var(--liberal-dark));
}

.btn-secondary {
    padding: 10px 16px;
    font-size: 0.85rem;
    border: 2px solid var(--text-secondary);
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn-secondary:active {
    background: var(--bg-card);
}

.btn-secondary:disabled {
    opacity: 0.5;
}

/* Role Screen */
#role-screen {
    align-items: center;
    justify-content: center;
    text-align: center;
}

.role-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
}

#role-player-name, #vote-player-name {
    font-size: 1.8rem;
    color: var(--liberal-color);
    word-break: break-word;
}

.role-card {
    width: 220px;
    height: 300px;
}

.role-card-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    border-radius: 16px;
    padding: 20px;
}

.role-card.liberal .role-card-inner {
    background: linear-gradient(135deg, var(--liberal-color), var(--liberal-dark));
}

.role-card.fascist .role-card-inner {
    background: linear-gradient(135deg, var(--fascist-color), var(--fascist-dark));
}

.role-card.hitler .role-card-inner {
    background: linear-gradient(135deg, var(--hitler-color), #4a0000);
}

#role-title {
    font-size: 1.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#role-team {
    font-size: 1.1rem;
    opacity: 0.9;
}

#role-description {
    font-size: 0.9rem;
    opacity: 0.8;
    text-align: center;
    line-height: 1.4;
}

.role-instruction {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Game Screen */
#game-screen {
    padding: 10px;
    gap: 10px;
}

.game-header {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 12px;
    position: relative;
}

.btn-new-game {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 10px;
    font-size: 0.7rem;
    border: 1px solid var(--text-secondary);
    border-radius: 5px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-new-game:active {
    background: var(--fascist-color);
    border-color: var(--fascist-color);
    color: white;
}

.policy-tracks {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.liberal-track, .fascist-track {
    text-align: center;
}

.liberal-track h3, .fascist-track h3 {
    font-size: 0.75rem;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.liberal-track h3 {
    color: var(--liberal-color);
}

.fascist-track h3 {
    color: var(--fascist-color);
}

.track-slots {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.slot {
    width: 38px;
    height: 50px;
    border: 2px solid var(--bg-card);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: var(--text-secondary);
    position: relative;
}

.liberal-track .slot.filled {
    background: var(--liberal-color);
    border-color: var(--liberal-color);
}

.fascist-track .slot.filled {
    background: var(--fascist-color);
    border-color: var(--fascist-color);
}

.slot .power-icon {
    font-size: 0.9rem;
}

.slot.win-slot::after {
    content: 'WIN';
    position: absolute;
    bottom: 2px;
    font-size: 0.5rem;
    font-weight: bold;
}

.election-tracker {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.election-tracker span {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.tracker-slots {
    display: flex;
    gap: 4px;
}

.tracker-slot {
    width: 22px;
    height: 22px;
    border: 2px solid var(--warning);
    border-radius: 50%;
}

.tracker-slot.filled {
    background: var(--warning);
}

.tracker-slot.chaos-slot {
    border-color: var(--fascist-color);
}

.tracker-slot.chaos-slot.filled {
    background: var(--fascist-color);
}

/* Game Main Area - Stacked for mobile */
.game-main {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* Government Display */
.government-display {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: 10px;
}

.gov-role {
    text-align: center;
}

.gov-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 3px;
}

.gov-name {
    display: block;
    font-size: 1rem;
    font-weight: bold;
}

/* Player List */
.player-list {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 10px;
}

.player-list h3 {
    font-size: 0.75rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

#player-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: var(--bg-card);
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    font-size: 0.85rem;
    -webkit-tap-highlight-color: transparent;
}

.player-item:active:not(.dead):not(.not-selectable) {
    border-color: var(--liberal-color);
}

.player-item.president {
    border-color: var(--warning);
    background: rgba(255, 152, 0, 0.2);
}

.player-item.chancellor {
    border-color: var(--success);
    background: rgba(76, 175, 80, 0.2);
}

.player-item.term-limited {
    opacity: 0.5;
}

.player-item.dead {
    opacity: 0.3;
    text-decoration: line-through;
    cursor: default;
}

.player-item.not-selectable {
    cursor: default;
}

.player-name {
    font-weight: 500;
}

.player-badges {
    display: flex;
    gap: 3px;
}

.badge {
    font-size: 0.55rem;
    padding: 2px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: bold;
}

.badge.president {
    background: var(--warning);
    color: black;
}

.badge.chancellor {
    background: var(--success);
    color: white;
}

.badge.investigated {
    background: var(--liberal-color);
    color: white;
}

.badge.dead {
    background: var(--fascist-color);
    color: white;
}

.badge.term-limited {
    background: var(--bg-primary);
    color: var(--text-secondary);
}

/* Game Actions */
.game-actions {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#action-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

#action-panel h3 {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#action-panel p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Game Log - Collapsible on mobile */
.game-log {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 10px;
    max-height: 120px;
    overflow-y: auto;
}

.game-log h3 {
    font-size: 0.75rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

#log-entries {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.log-entry {
    padding: 8px;
    background: var(--bg-card);
    border-radius: 5px;
    font-size: 0.75rem;
    border-left: 3px solid var(--text-secondary);
}

.log-entry.liberal {
    border-left-color: var(--liberal-color);
}

.log-entry.fascist {
    border-left-color: var(--fascist-color);
}

.log-entry.election {
    border-left-color: var(--success);
}

.log-entry.failed {
    border-left-color: var(--warning);
}

/* Vote Screen */
#vote-screen {
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 20px;
}

.vote-government {
    background: var(--bg-secondary);
    padding: 15px 25px;
    border-radius: 10px;
    font-size: 1rem;
}

.vote-government p {
    margin: 6px 0;
}

.vote-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
}

.vote-buttons {
    display: flex;
    gap: 20px;
}

.btn-vote {
    width: 110px;
    height: 110px;
    font-size: 1.5rem;
    font-weight: bold;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-ja {
    background: linear-gradient(135deg, var(--success), #2e7d32);
    color: white;
}

.btn-ja:active {
    transform: scale(0.95);
}

.btn-nein {
    background: linear-gradient(135deg, var(--fascist-color), var(--fascist-dark));
    color: white;
}

.btn-nein:active {
    transform: scale(0.95);
}

#vote-results {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 100%;
    padding: 0 10px;
}

.vote-result-item {
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.85rem;
}

.vote-result-item.ja {
    background: rgba(76, 175, 80, 0.3);
    border: 2px solid var(--success);
}

.vote-result-item.nein {
    background: rgba(244, 67, 54, 0.3);
    border: 2px solid var(--fascist-color);
}

#vote-outcome {
    font-size: 1.4rem;
    margin-top: 10px;
}

#vote-outcome.passed {
    color: var(--success);
}

#vote-outcome.failed {
    color: var(--fascist-color);
}

/* Action Screen */
#action-screen {
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 20px;
    padding: 20px;
}

#action-title {
    font-size: 1.3rem;
}

#action-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#action-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
}

.action-players {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    width: 100%;
}

.action-player-btn {
    padding: 12px 20px;
    font-size: 1rem;
    border: 2px solid var(--bg-card);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.action-player-btn:active {
    border-color: var(--liberal-color);
    background: var(--bg-card);
}

.action-player-btn:disabled {
    opacity: 0.4;
}

/* Game Over Screen */
#gameover-screen {
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 20px;
    padding: 20px;
}

#winner-team {
    font-size: 1.8rem;
    text-transform: uppercase;
    letter-spacing: 3px;
}

#winner-team.liberal {
    color: var(--liberal-color);
}

#winner-team.fascist {
    color: var(--fascist-color);
}

#win-reason {
    font-size: 1rem;
    color: var(--text-secondary);
}

#role-reveal-all {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 100%;
}

.revealed-role {
    padding: 10px 15px;
    border-radius: 8px;
    text-align: center;
}

.revealed-role.liberal {
    background: rgba(33, 150, 243, 0.3);
    border: 2px solid var(--liberal-color);
}

.revealed-role.fascist {
    background: rgba(244, 67, 54, 0.3);
    border: 2px solid var(--fascist-color);
}

.revealed-role.hitler {
    background: rgba(183, 28, 28, 0.5);
    border: 2px solid var(--hitler-color);
}

.revealed-role .name {
    font-weight: bold;
    font-size: 0.95rem;
}

.revealed-role .role {
    font-size: 0.75rem;
    opacity: 0.8;
    text-transform: uppercase;
}

/* Legislative buttons */
.legislative-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 250px;
}

.legislative-buttons .btn-primary {
    width: 100%;
}

.veto-available {
    color: var(--warning) !important;
    font-size: 0.85rem;
}

/* Animations */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.pulse {
    animation: pulse 2s infinite;
}

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

.fade-in {
    animation: fadeIn 0.2s ease-out;
}

/* Prevent text selection on buttons */
button {
    -webkit-user-select: none;
    user-select: none;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-card);
    border-radius: 2px;
}

/* Policy Cards for Legislative Session */
.policy-cards {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 15px 0;
}

.policy-card {
    width: 70px;
    height: 100px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
    border: 3px solid transparent;
}

.policy-card:active {
    transform: scale(0.95);
}

.policy-card.liberal {
    background: linear-gradient(135deg, var(--liberal-color), var(--liberal-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.4);
}

.policy-card.fascist {
    background: linear-gradient(135deg, var(--fascist-color), var(--fascist-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.4);
}

.policy-card.selected {
    border-color: var(--warning);
    transform: scale(1.05);
}

/* Deck info display */
.deck-info {
    background: var(--bg-card);
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 10px;
}

/* Legislative pass screen */
.legislative-pass {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.legislative-pass h3 {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.legislative-pass h2 {
    color: var(--liberal-color);
    font-size: 1.5rem;
}

/* Policy selection instruction */
.policy-instruction {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 10px;
}

/* Veto buttons */
.veto-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 250px;
}

.btn-veto {
    padding: 14px 30px;
    font-size: 1rem;
    font-weight: bold;
    border: 2px solid var(--warning);
    border-radius: 10px;
    background: transparent;
    color: var(--warning);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-veto:active {
    background: var(--warning);
    color: black;
}
