* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Hiragino Kaku Gothic ProN', 'メイリオ', sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
}

/* ヘッダー */
.site-header {
    width: 100%;
    background: #111827;
    color: white;
    padding: 8px 16px;
}

.header-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.1em;
}

.header-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    margin: 20px;
    padding: 40px;
    max-width: 1200px;
    width: 100%;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 2em;
}

.problem-selector {
    background: #e8f4f8;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 2px solid #3498db;
}

.problem-selector h3 {
    margin-bottom: 12px;
    color: #2c3e50;
    font-size: 1.1em;
}

.problem-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.problem-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 15px;
    background: white;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 100px;
    position: relative;
}

.problem-btn:hover {
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.problem-btn.active {
    background: #3498db;
    border-color: #3498db;
    color: white;
}

.problem-btn.active .problem-difficulty {
    color: #e8f4f8;
}

.clear-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #27ae60;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.problem-name {
    font-weight: bold;
    font-size: 0.9em;
}

.problem-difficulty {
    font-size: 0.8em;
    color: #e67e22;
    margin-top: 4px;
}

.problem-desc {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    border-left: 4px solid #3498db;
}

.problem-desc p {
    margin-bottom: 10px;
    line-height: 1.6;
    color: #555;
}

.game-area {
    display: grid;
    grid-template-columns: 1fr 3fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
    align-items: start;
}

.side {
    background: #ecf0f1;
    padding: 20px;
    border-radius: 10px;
    min-height: 200px;
    position: relative;
    transition: background-color 0.5s;
}

.side.danger {
    background: linear-gradient(135deg, #ffcccc 0%, #ff9999 100%);
    animation: danger-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes danger-pulse {
    from { box-shadow: 0 0 10px rgba(255, 0, 0, 0.3); }
    to { box-shadow: 0 0 25px rgba(255, 0, 0, 0.6); }
}

.flood-container {
    position: absolute;
    bottom: -60px;
    left: 0;
    right: 0;
    font-size: 2em;
    text-align: center;
    transition: all 0.3s;
}

.flood {
    animation: flood-wave 0.5s ease-in-out infinite alternate;
    display: inline-block;
}

@keyframes flood-wave {
    from { transform: translateY(0) scale(1); }
    to { transform: translateY(-8px) scale(1.1); }
}

.flood-progress-container {
    width: 100%;
    height: 20px;
    background: #ddd;
    border-radius: 10px;
    margin-top: 10px;
    overflow: hidden;
    position: relative;
}

.flood-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #1a5276);
    border-radius: 10px;
    transition: width 0.1s linear;
    position: relative;
}

.flood-progress-bar::after {
    content: '🌊';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5em;
}

.side h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    text-align: center;
}

.person {
    background: white;
    padding: 12px;
    margin: 8px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border: 3px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.person:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.person.selected {
    border-color: #3498db;
    background: #e3f2fd;
}

.person.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.person.crossing {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
}

.person-name {
    font-weight: bold;
    color: #2c3e50;
}

.person-time {
    background: #3498db;
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.9em;
}

.bridge {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    position: relative;
}

.river-area {
    width: 100%;
    height: 200px;
    background: linear-gradient(to bottom, #1a5276 0%, #2e86ab 30%, #3498db 50%, #2e86ab 70%, #1a5276 100%);
    border-radius: 10px;
    position: relative;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.3);
    overflow: hidden;
}

.river-area::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 100%;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 20px,
        rgba(255,255,255,0.1) 20px,
        rgba(255,255,255,0.1) 40px
    );
    animation: wave-flow 3s linear infinite;
}

@keyframes wave-flow {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.riverbank {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 15px;
    background: linear-gradient(to bottom, #6b4423 0%, #8b5a2b 50%, #6b4423 100%);
}

.riverbank.left {
    left: 0;
    border-radius: 10px 0 0 10px;
}

.riverbank.right {
    right: 0;
    border-radius: 0 10px 10px 0;
}

.boat {
    position: absolute;
    font-size: 3em;
    transition: left 0.3s ease;
}

.boat.on-left {
    left: 20px;
}

.boat.on-right {
    left: calc(100% - 80px);
}

.controls {
    display: flex;
    gap: 10px;
    flex-direction: column;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

.cross-btn {
    background: #3498db;
    color: white;
}

.cross-btn:hover:not(:disabled) {
    background: #2980b9;
    transform: scale(1.05);
}

.cross-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    opacity: 0.6;
}

.reset-btn {
    background: #e74c3c;
    color: white;
}

.reset-btn:hover {
    background: #c0392b;
}

.show-solution-btn {
    background: #27ae60;
    color: white;
}

.show-solution-btn:hover {
    background: #229954;
}

.status {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.status-label {
    color: #7f8c8d;
}

.status-value {
    font-weight: bold;
    color: #2c3e50;
}

.time-elapsed {
    color: #e74c3c;
    font-size: 1.3em;
}

.history {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-top: 20px;
}

.history h4 {
    margin-bottom: 10px;
    color: #2c3e50;
}

.history-item {
    padding: 8px;
    background: white;
    margin: 5px 0;
    border-radius: 5px;
    border-left: 3px solid #3498db;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    margin-top: 20px;
    border: 2px solid #28a745;
}

.solution {
    background: #fff3cd;
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
    border-left: 4px solid #ffc107;
}

.solution h4 {
    color: #856404;
    margin-bottom: 15px;
}

.solution-step {
    padding: 10px;
    background: white;
    margin: 8px 0;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.step-action {
    color: #2c3e50;
}

.step-time {
    background: #ffc107;
    color: #000;
    padding: 4px 12px;
    border-radius: 15px;
    font-weight: bold;
}

.animation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
    display: none;
}

.animation-overlay.active {
    display: block;
}

.crossing-boat {
    position: absolute;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: none;
}

.boat-passengers {
    display: flex;
    gap: 5px;
    margin-bottom: -15px;
    z-index: 2;
}

.boat-passenger {
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid #3498db;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 5px;
}

.boat-emoji {
    font-size: 4em;
    animation: boat-rock 0.8s ease-in-out infinite;
    filter: drop-shadow(0 4px 4px rgba(0,0,0,0.3));
}

@keyframes boat-rock {
    0%, 100% { transform: rotate(-3deg) translateY(0); }
    50% { transform: rotate(3deg) translateY(-5px); }
}

.water-splash {
    position: absolute;
    font-size: 1.5em;
    opacity: 0.8;
    animation: splash 0.5s ease-out infinite;
}

@keyframes splash {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0; }
}

.timer-display {
    font-size: 2.5em;
    font-weight: bold;
    text-align: center;
    padding: 15px;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: #fff;
    border-radius: 10px;
    margin-bottom: 20px;
    font-family: 'Courier New', monospace;
}

.timer-display.warning {
    background: linear-gradient(135deg, #e67e22, #d35400);
    animation: timer-warning 0.5s ease-in-out infinite alternate;
}

.timer-display.critical {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    animation: timer-critical 0.3s ease-in-out infinite alternate;
}

@keyframes timer-warning {
    from { transform: scale(1); }
    to { transform: scale(1.02); }
}

@keyframes timer-critical {
    from { transform: scale(1); background: #c0392b; }
    to { transform: scale(1.05); background: #e74c3c; }
}

.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.game-over-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
}

.game-over-content h2 {
    font-size: 2em;
    margin-bottom: 20px;
}

.game-over-content.lose h2 {
    color: #e74c3c;
}

.game-over-content.win h2 {
    color: #27ae60;
}

.game-over-content p {
    font-size: 1.2em;
    margin-bottom: 20px;
    color: #555;
}

.start-btn {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    font-size: 1.2em;
    padding: 15px 30px;
}

.start-btn:hover {
    background: linear-gradient(135deg, #229954, #27ae60);
    transform: scale(1.05);
}

.eaten-person {
    text-decoration: line-through;
    opacity: 0.5;
    background: #ffcccc !important;
}
