* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 20px;
    padding-top: 80px;
    font-family: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
    background: linear-gradient(to bottom, #000428 0%, #004e92 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
}

/* ヘッダースタイル */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 0;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.header-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    font-weight: 600;
    color: white;
    text-decoration: none;
    font-size: 1.1rem;
    transition: color 0.3s ease;
}

.header-link:hover {
    color: #60a5fa;
}

.header-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20% 30%, white, transparent),
        radial-gradient(2px 2px at 60% 70%, white, transparent),
        radial-gradient(1px 1px at 50% 50%, white, transparent),
        radial-gradient(1px 1px at 80% 10%, white, transparent),
        radial-gradient(2px 2px at 90% 60%, white, transparent),
        radial-gradient(1px 1px at 33% 80%, white, transparent),
        radial-gradient(1px 1px at 15% 55%, white, transparent);
    background-size: 200% 200%;
    background-position: 0% 0%;
    animation: twinkle 200s linear infinite;
    opacity: 0.6;
    pointer-events: none;
    z-index: 1;
}

@keyframes twinkle {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 200%; }
}

.container {
    background: rgba(10, 10, 30, 0.85);
    border-radius: 20px;
    padding: 40px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 100px rgba(100, 150, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 2;
}

h1 {
    text-align: center;
    color: #ffffff;
    margin-bottom: 10px;
    font-size: 2em;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5), 0 0 40px rgba(100, 150, 255, 0.3);
}

.subtitle {
    text-align: center;
    color: #b8c5db;
    margin-bottom: 30px;
    font-size: 0.9em;
}

.input-section {
    margin-bottom: 30px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #b8c5db;
    font-weight: bold;
}

input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
    background: rgba(20, 20, 50, 0.5);
    color: #ffffff;
}

input[type="text"]:focus {
    outline: none;
    border-color: #26d0ce;
    box-shadow: 0 0 15px rgba(38, 208, 206, 0.3);
}

.char-limit {
    text-align: right;
    color: #8899bb;
    font-size: 0.85em;
    margin-top: 5px;
}

.error-message {
    background: rgba(220, 53, 69, 0.2);
    color: #ff6b81;
    padding: 10px;
    border-radius: 8px;
    margin-top: 10px;
    font-size: 0.9em;
    display: none;
    border: 1px solid rgba(220, 53, 69, 0.3);
}

button {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #1a2980 0%, #26d0ce 100%);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(38, 208, 206, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(38, 208, 206, 0.5), 0 0 30px rgba(38, 208, 206, 0.3);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #333;
    cursor: not-allowed;
    transform: none;
    opacity: 0.5;
    box-shadow: none;
}

.game-section {
    display: none;
    margin-top: 30px;
}

.stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(20, 20, 50, 0.5);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: 0.85em;
    color: #b8c5db;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #26d0ce;
    text-shadow: 0 0 10px rgba(38, 208, 206, 0.5);
}

.qr-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    padding: 15px;
    border-radius: 12px;
    transition: all 0.5s ease;
}

.qr-container.error {
    background: rgba(220, 53, 69, 0.2);
    box-shadow: 0 0 40px rgba(220, 53, 69, 0.4), inset 0 0 20px rgba(220, 53, 69, 0.2);
    border: 2px solid rgba(220, 53, 69, 0.5);
}

#qrCanvas {
    border: 2px solid #1a1a3e;
    border-radius: 10px;
    cursor: crosshair;
    background: #000000;
    box-shadow: 0 0 30px rgba(100, 150, 255, 0.3);
    transition: box-shadow 0.5s ease;
}

.qr-container.error #qrCanvas {
    box-shadow: 0 0 40px rgba(255, 50, 50, 0.6);
    border-color: #ff3232;
}

.status {
    text-align: center;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    font-weight: bold;
}

.status.success {
    background: rgba(40, 167, 69, 0.2);
    color: #5fff8d;
    border: 1px solid rgba(40, 167, 69, 0.3);
    text-shadow: 0 0 10px rgba(95, 255, 141, 0.3);
}

.status.error {
    background: rgba(220, 53, 69, 0.2);
    color: #ff6b81;
    border: 1px solid rgba(220, 53, 69, 0.3);
    text-shadow: 0 0 10px rgba(255, 107, 129, 0.3);
}

.controls {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.controls button {
    flex: 1;
}

.game-over-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
}

.game-over {
    text-align: center;
    padding: 40px;
    background: linear-gradient(135deg, #1a2980 0%, #26d0ce 100%);
    color: white;
    border-radius: 15px;
    box-shadow: 0 0 60px rgba(38, 208, 206, 0.6);
    max-width: 500px;
    width: 100%;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.game-over h2 {
    margin-bottom: 20px;
    font-size: 1.8em;
}

.game-result {
    margin: 20px 0;
}

.result-label {
    font-size: 0.9em;
    opacity: 0.9;
    margin-bottom: 5px;
}

.game-over .score {
    font-size: 3.5em;
    margin: 10px 0;
    font-weight: bold;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.result-details {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
}

.result-label-small {
    font-size: 0.85em;
    opacity: 0.8;
}

.result-value {
    font-weight: bold;
    font-size: 1em;
}

.rating {
    font-size: 2.5em;
    margin: 15px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.rating-title {
    font-size: 1.3em;
    margin-top: 10px;
    margin-bottom: 5px;
    font-weight: bold;
    letter-spacing: 1px;
}

.rating-message {
    font-size: 1em;
    margin-top: 10px;
    opacity: 0.9;
    font-style: italic;
}

.modal-button {
    margin-top: 25px;
    padding: 15px 40px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.modal-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.3);
}

.modal-button:active {
    transform: translateY(0);
}

.rating.special {
    animation: sparkle 1.5s infinite;
}

.rating.legendary {
    animation: rainbow 2s linear infinite;
    font-size: 3em;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes rainbow {
    0% { color: #ff0000; }
    16% { color: #ff8800; }
    33% { color: #ffff00; }
    50% { color: #00ff00; }
    66% { color: #0088ff; }
    83% { color: #8800ff; }
    100% { color: #ff0000; }
}

/* トースト通知 */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(150px);
    background: rgba(10, 10, 30, 0.95);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 30px rgba(38, 208, 206, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-weight: bold;
    z-index: 10000;
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
    opacity: 0;
    backdrop-filter: blur(10px);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    border-color: rgba(40, 167, 69, 0.5);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 30px rgba(95, 255, 141, 0.4);
}

.toast.error {
    border-color: rgba(220, 53, 69, 0.5);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 107, 129, 0.4);
}

.toast.info {
    border-color: rgba(38, 208, 206, 0.5);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 30px rgba(38, 208, 206, 0.4);
}

/* 記録表示 */
.records {
    margin-top: 30px;
    padding: 20px;
    background: rgba(20, 20, 50, 0.5);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.records h3 {
    color: #ffffff;
    margin: 0 0 15px 0;
    text-align: center;
    font-size: 1.1em;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.records-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.record-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: rgba(10, 10, 30, 0.6);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.record-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(38, 208, 206, 0.2);
}

.record-rank {
    font-size: 1.2em;
    font-weight: bold;
    color: #26d0ce;
    text-shadow: 0 0 10px rgba(38, 208, 206, 0.5);
    min-width: 30px;
}

.record-info {
    flex: 1;
    margin: 0 15px;
}

.record-text {
    color: #ffffff;
    font-weight: bold;
    margin-bottom: 4px;
    word-break: break-all;
}

.record-date {
    color: #8899bb;
    font-size: 0.85em;
}

.record-score {
    font-size: 1.5em;
    font-weight: bold;
    color: #26d0ce;
    text-shadow: 0 0 10px rgba(38, 208, 206, 0.5);
}

.no-records {
    text-align: center;
    color: #8899bb;
    padding: 20px;
    font-style: italic;
}
