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

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    overflow-x: hidden;
}

.container {
    text-align: center;
}

h1 {
    color: #e8d5b7;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
}

.header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.btn-help {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid rgba(232, 213, 183, 0.4);
    color: rgba(232, 213, 183, 0.6);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-help:hover {
    border-color: #e8d5b7;
    color: #e8d5b7;
    background: rgba(232, 213, 183, 0.1);
}

/* Help Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid #e8d5b7;
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    text-align: left;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: #e8d5b7;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: #fff;
}

.modal-content h2 {
    color: #e8d5b7;
    margin-bottom: 20px;
    text-align: center;
}

.help-section {
    margin-bottom: 20px;
}

.help-section h3 {
    color: #4a9eff;
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.help-section p {
    color: #ccc;
    line-height: 1.5;
    margin-bottom: 8px;
}

.help-section ul {
    color: #ccc;
    margin-left: 20px;
    line-height: 1.8;
}

.help-section li strong {
    color: #e8d5b7;
}

.help-method {
    background: rgba(0, 0, 0, 0.2);
    border-left: 3px solid #4a9eff;
    padding: 10px 12px;
    margin: 10px 0;
    border-radius: 0 8px 8px 0;
}

.help-method strong {
    color: #e8d5b7;
    display: block;
    margin-bottom: 5px;
}

.help-method p {
    margin: 0;
    font-size: 0.9rem;
}

.game-wrapper {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 30px;
}

@media (max-width: 900px) {
    .game-wrapper {
        flex-direction: column;
        align-items: center;
    }
}

.board-container {
    position: relative;
    width: 480px;
    max-width: calc(100vw - 40px);
}

.board {
    width: 100%;
    max-width: 480px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    overflow: hidden;
}

.arrows-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.info-panel {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
    min-width: 280px;
    max-width: 320px;
}

@media (max-width: 900px) {
    .info-panel {
        align-items: center;
    }
}

/* Voting method indicator */
.voting-method-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(232, 213, 183, 0.2);
}

.voting-method-label {
    color: #8b9dc3;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.voting-method {
    color: #e8d5b7;
    font-weight: 600;
    font-size: 0.9rem;
}

.voting-method.method-fptp {
    color: #60a5fa; /* Blue for FPTP */
}

.voting-method.method-approval {
    color: #34d399; /* Green for Approval */
}

.voting-method.method-irv {
    color: #f472b6; /* Pink for IRV */
}

/* Difficulty indicator */
.difficulty-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 14px;
    border-radius: 16px;
    border: 1px solid rgba(232, 213, 183, 0.15);
    margin-top: 6px;
}

.difficulty-label {
    color: #8b9dc3;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.difficulty-display {
    font-weight: 600;
    font-size: 0.85rem;
    font-family: 'Monaco', 'Consolas', monospace;
    transition: color 0.3s ease;
}

.difficulty-display.easy {
    color: #4ade80; /* Green for easy */
}

.difficulty-display.medium {
    color: #fbbf24; /* Yellow/amber for medium */
}

.difficulty-display.hard {
    color: #f87171; /* Red for hard */
}

/* Timer styles */
.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.timer-label {
    color: #8b9dc3;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.timer {
    font-size: 3rem;
    font-weight: 700;
    color: #e8d5b7;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 20px rgba(232, 213, 183, 0.3);
    transition: color 0.3s ease;
}

/* Skip timer styles */
.skip-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.btn-skip {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    font-size: 0.85rem;
    padding: 8px 16px;
    min-width: 80px;
}

.btn-skip:hover:not(:disabled) {
    box-shadow: 0 5px 20px rgba(59, 130, 246, 0.4);
}

.btn-skip:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-skip.active {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.4);
}

.skip-count {
    color: #8b9dc3;
    font-size: 0.9rem;
    min-width: 40px;
}

.skip-count.threshold-met {
    color: #22c55e;
    font-weight: 600;
}

.timer.warning {
    color: #f4a261;
}

.timer.urgent {
    color: #e76f51;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Vote display (approval voting) */
.vote-display {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 16px;
    border-radius: 6px;
    border: 1px solid rgba(232, 213, 183, 0.1);
}

.vote-label {
    color: #8b9dc3;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.current-vote {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.current-vote .none {
    color: #6b7280;
    font-style: italic;
    font-size: 0.9rem;
}

.my-vote-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(201, 162, 39, 0.2);
    border: 1px solid rgba(201, 162, 39, 0.4);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.95rem;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

/* IRV mode: stack votes vertically */
.current-vote.irv-mode {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}

.current-vote.irv-mode .my-vote-item {
    display: flex;
    width: 100%;
    cursor: grab;
}

.current-vote.irv-mode .my-vote-item:active {
    cursor: grabbing;
}

/* Drag handle for IRV */
.drag-handle {
    color: #6b7280;
    font-size: 0.8rem;
    cursor: grab;
    padding: 0 4px;
    user-select: none;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.drag-handle:hover {
    opacity: 1;
}

.my-vote-item:active .drag-handle {
    cursor: grabbing;
}

/* Rank badge for IRV */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #f472b6 0%, #db2777 100%);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
    font-family: inherit;
}

/* Top choice gets special badge color */
.my-vote-item[data-index="0"] .rank-badge {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

/* Drag states */
.my-vote-item.dragging {
    opacity: 0.5;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.my-vote-item.drag-over {
    border-color: #f472b6;
    background: rgba(244, 114, 182, 0.2);
    transform: translateY(2px);
}

.my-vote-item.surrender {
    background: rgba(220, 38, 38, 0.2);
    border-color: rgba(220, 38, 38, 0.4);
}

.my-vote-item.surrender .my-vote-text {
    color: #f87171;
}

.my-vote-item.surrender .rank-badge {
    background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
}

.my-vote-text {
    color: #e8d5b7;
    flex: 1;
}

.remove-vote-btn {
    background: none;
    border: none;
    color: #8b9dc3;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
}

.remove-vote-btn:hover {
    opacity: 1;
    color: #f87171;
}

/* Vote tallies panel */
.votes-panel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(232, 213, 183, 0.15);
    border-radius: 8px;
    padding: 15px;
    min-width: 280px;
    max-width: 320px;
}

.votes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(232, 213, 183, 0.1);
}

.votes-header span:first-child {
    color: #e8d5b7;
    font-weight: 600;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.voter-count {
    color: #8b9dc3;
    font-size: 0.85rem;
}

.votes-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
}

.no-votes {
    color: #6b7280;
    font-style: italic;
    font-size: 0.9rem;
    text-align: center;
    padding: 10px;
}

.vote-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 12px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.vote-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.vote-item.leading {
    background: rgba(201, 162, 39, 0.15);
    border: 1px solid rgba(201, 162, 39, 0.3);
}

.vote-item.surrender {
    background: rgba(220, 38, 38, 0.15);
    border: 1px solid rgba(220, 38, 38, 0.3);
}

.vote-item.surrender .vote-move {
    color: #f87171;
}

.vote-item.surrender .vote-bar {
    background: #dc2626;
}

.vote-move {
    color: #e8d5b7;
    font-weight: 500;
    font-family: monospace;
    font-size: 1rem;
}

.vote-count {
    display: flex;
    align-items: center;
    gap: 6px;
}

.vote-bar {
    height: 6px;
    background: #c9a227;
    border-radius: 3px;
    min-width: 10px;
    transition: width 0.3s ease;
}

.vote-number {
    color: #8b9dc3;
    font-size: 0.85rem;
    min-width: 45px;
    text-align: right;
}

.btn {
    background: linear-gradient(135deg, #c9a227 0%, #8b7355 100%);
    color: #1a1a2e;
    border: none;
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(201, 162, 39, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.btn-surrender {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    font-size: 0.9rem;
    padding: 10px 20px;
}

.btn-surrender:hover {
    box-shadow: 0 5px 20px rgba(107, 114, 128, 0.4);
}

.btn-surrender:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-surrender.voted {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.4);
}

/* Chessboard customization */
.board-b72b1 {
    border: 4px solid #c9a227;
    border-radius: 4px;
}

@media (max-width: 520px) {
    .board-container {
        width: calc(100vw - 40px);
        max-width: 400px;
    }
    
    .board {
        width: 100%;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    .container {
        width: 100%;
        padding: 0 10px;
    }
}

/* Game Over Overlay */
.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.5s ease;
}

.game-over-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.game-over-content {
    text-align: center;
    padding: 30px 50px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid #c9a227;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.game-over-content h2 {
    color: #e8d5b7;
    font-size: 2rem;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.game-over-content p {
    color: #8b9dc3;
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.restart-countdown {
    color: #c9a227 !important;
    font-size: 1.2rem !important;
    font-weight: 600;
    margin-top: 10px;
}

/* Move History Panel */
.history-panel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(232, 213, 183, 0.15);
    border-radius: 8px;
    padding: 12px;
    min-width: 280px;
    max-width: 320px;
}

.history-header {
    color: #e8d5b7;
    font-weight: 600;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(232, 213, 183, 0.1);
}

.move-history {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: 100px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.9rem;
}

.no-moves {
    color: #6b7280;
    font-style: italic;
    font-family: inherit;
}

.move-pair {
    display: inline-flex;
    gap: 6px;
    background: rgba(255, 255, 255, 0.03);
    padding: 3px 8px;
    border-radius: 4px;
    align-items: center;
}

.move-number {
    color: #6b7280;
    font-size: 0.8rem;
}

.white-move {
    color: #e8d5b7;
}

.black-move {
    color: #8b9dc3;
}

/* Winner styles */
.winner-white .game-over-content {
    border-color: #e8d5b7;
}

.winner-black .game-over-content {
    border-color: #4a5568;
}

.winner-draw .game-over-content {
    border-color: #8b9dc3;
}

