* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #fff;
}

/* ヘッダースタイル */
.header {
    background-color: #1a1a1a;
    color: white;
    padding: 10px 0;
    width: 100%;
    margin: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.header-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    color: white;
    text-decoration: none;
    font-weight: bold;
    font-size: 18px;
}

.header-link:hover {
    opacity: 0.8;
}

.header-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    margin: 20px auto;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

h1 {
    font-size: 3em;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.subtitle {
    text-align: center;
    font-size: 1.2em;
    margin-bottom: 30px;
    opacity: 0.9;
}

.operators-guide {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 30px;
}

.operators-guide h3 {
    font-size: 1.3em;
    text-align: center;
    margin-bottom: 15px;
    color: #fbd38d;
}

.operators-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.operator-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 8px;
    font-size: 1em;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.operator-item .op {
    color: #f6ad55;
    font-weight: bold;
    font-size: 1.3em;
    margin-right: 8px;
}

.operator-item .example {
    font-size: 0.85em;
    color: #4fd1c5;
    opacity: 0.9;
    font-family: 'Courier New', monospace;
    margin-top: 3px;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2em;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Courier New', monospace;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.start-button {
    display: block;
    margin: 0 auto;
    font-size: 1.5em;
    padding: 20px 60px;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    box-shadow: 0 6px 20px rgba(72, 187, 120, 0.4);
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    font-size: 1.2em;
}

.info-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 10px;
}

.back-to-title-button {
    background: linear-gradient(135deg, #f6ad55 0%, #ed8936 100%);
    padding: 10px 20px;
    font-size: 0.9em;
    box-shadow: 0 4px 15px rgba(246, 173, 85, 0.3);
}

.timer-circle {
    position: relative;
    width: 80px;
    height: 80px;
}

.timer-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 8;
}

.timer-progress {
    fill: none;
    stroke: #4fd1c5;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.1s linear, stroke 0.3s;
}

.timer-progress.warning {
    stroke: #f6ad55;
}

.timer-progress.danger {
    stroke: #fc8181;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1em;
    font-weight: bold;
    color: #fff;
}

.question-display {
    background: rgba(0, 0, 0, 0.3);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    margin-bottom: 30px;
    font-size: 2em;
    letter-spacing: 3px;
}

.operand {
    color: #4fd1c5;
    font-weight: bold;
}

.operator {
    color: #f6ad55;
    margin: 0 15px;
    font-size: 1.2em;
}

.input-display {
    background: rgba(0, 0, 0, 0.4);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.8em;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #90cdf4;
    letter-spacing: 5px;
}

.input-placeholder {
    opacity: 0.5;
}

.feedback {
    background: rgba(0, 0, 0, 0.5);
    padding: 15px 20px;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 20px;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.feedback.show {
    opacity: 1;
    transform: scale(1);
}

.feedback.correct {
    background: rgba(72, 187, 120, 0.3);
    border: 2px solid #48bb78;
}

.feedback.incorrect {
    background: rgba(245, 101, 101, 0.3);
    border: 2px solid #f56565;
}

.feedback-icon {
    font-size: 2.5em;
    font-weight: bold;
    margin-bottom: 5px;
    animation: popIn 0.4s ease;
}

.feedback.correct .feedback-icon {
    color: #48bb78;
}

.feedback.incorrect .feedback-icon {
    color: #f56565;
}

.feedback-text {
    font-size: 1.3em;
    font-weight: bold;
    margin-bottom: 5px;
}

.feedback-answer {
    font-size: 1em;
    opacity: 0.9;
    margin-top: 3px;
    color: #fbd38d;
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.input-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.bit-button {
    font-size: 2em;
    padding: 20px;
    background: linear-gradient(135deg, #4fd1c5 0%, #38b2ac 100%);
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.clear-button {
    background: linear-gradient(135deg, #fc8181 0%, #f56565 100%);
}

.enter-button {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    font-size: 1.4em;
}

.result-stats {
    background: rgba(0, 0, 0, 0.3);
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.5em;
    margin: 15px 0;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.stat-label {
    color: #cbd5e0;
}

.stat-value {
    color: #4fd1c5;
    font-weight: bold;
}

.restart-button {
    display: block;
    margin: 0 auto;
    font-size: 1.3em;
    background: linear-gradient(135deg, #4fd1c5 0%, #38b2ac 100%);
    box-shadow: 0 6px 20px rgba(79, 209, 197, 0.4);
}

.rank-display {
    background: rgba(0, 0, 0, 0.4);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    margin-bottom: 30px;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.rank-label {
    font-size: 1.2em;
    color: #cbd5e0;
    margin-bottom: 10px;
    letter-spacing: 3px;
}

.rank-value {
    font-size: 5em;
    font-weight: bold;
    text-shadow: 0 0 20px currentColor, 0 0 40px currentColor;
    animation: rankAppear 0.6s ease-out;
    font-family: 'Impact', 'Arial Black', sans-serif;
}

.rank-value.rank-s {
    animation: rankAppear 0.6s ease-out, rankPulse 1.5s ease-in-out infinite;
}

@keyframes rankAppear {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    70% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

@keyframes rankPulse {
    0%, 100% {
        transform: scale(1);
        text-shadow: 0 0 20px currentColor, 0 0 40px currentColor;
    }
    50% {
        transform: scale(1.1);
        text-shadow: 0 0 30px currentColor, 0 0 60px currentColor, 0 0 80px currentColor;
    }
}

.top3-container {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 15px;
    margin: 30px 0;
}

.top3-title {
    font-size: 1.5em;
    text-align: center;
    margin-bottom: 15px;
    color: #fbd38d;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

.top3-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.top3-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 1.2em;
    transition: all 0.3s;
}

.top3-item.highlight {
    background: rgba(72, 187, 120, 0.3);
    border: 2px solid #48bb78;
    box-shadow: 0 0 15px rgba(72, 187, 120, 0.5);
    animation: pulse 1s ease-in-out;
}

.top3-item.empty {
    opacity: 0.5;
}

.top3-item .rank {
    color: #fbd38d;
    font-weight: bold;
    min-width: 50px;
}

.top3-item .score {
    color: #4fd1c5;
    font-weight: bold;
    font-size: 1.1em;
    letter-spacing: 2px;
    word-break: break-all;
    line-height: 1.4;
}

.no-record {
    text-align: center;
    padding: 20px;
    opacity: 0.7;
    font-size: 1.1em;
}

.clear-ranking-button {
    display: block;
    margin: 15px auto 0;
    padding: 10px 20px;
    font-size: 0.9em;
    background: linear-gradient(135deg, #fc8181 0%, #f56565 100%);
    box-shadow: 0 4px 15px rgba(252, 129, 129, 0.3);
}

.toast {
    position: fixed;
    bottom: -200px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 32, 44, 0.95);
    backdrop-filter: blur(10px);
    padding: 20px 30px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: bottom 0.4s ease;
    min-width: 300px;
    max-width: 90%;
}

.toast.show {
    bottom: 30px;
}

.toast-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.toast-message {
    color: #fff;
    font-size: 1.1em;
    text-align: center;
}

.toast-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.toast-button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Courier New', monospace;
}

.toast-button.confirm {
    background: linear-gradient(135deg, #fc8181 0%, #f56565 100%);
    color: white;
}

.toast-button.cancel {
    background: linear-gradient(135deg, #718096 0%, #4a5568 100%);
    color: white;
}

.toast-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 2em;
    }

    .question-display {
        font-size: 1.5em;
    }

    .input-display {
        font-size: 1.5em;
    }
}
