/* 色違いゲーム - Styles */

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

body {
    background: #1a1a2e;
    color: #eee;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    user-select: none;
    -webkit-user-select: none;
}

h1 {
    text-align: center;
    font-size: 1.6rem;
    margin-bottom: 12px;
    color: #f9c74f;
    text-shadow: 0 0 12px rgba(249, 199, 79, 0.5);
}

.hidden {
    display: none !important;
}

/* ---- Start screen ---- */
#start-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 420px;
    padding-bottom: 32px;
}

.start-logo {
    margin-bottom: 8px;
}

.logo-img {
    max-height: 60px;
    width: auto;
    display: block;
}

.name-input-area {
    width: 100%;
    margin-bottom: 16px;
}

.name-input-area label {
    display: block;
    font-size: 0.85rem;
    color: #aaa;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.name-input-area input {
    width: 100%;
    padding: 10px 14px;
    font-size: 1rem;
    border: 2px solid #2a2a4e;
    border-radius: 10px;
    background: #16213e;
    color: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.name-input-area input:focus {
    border-color: #f9c74f;
}

/* ---- Ranking ---- */
.ranking-area {
    width: 100%;
    margin-bottom: 16px;
}

.ranking-area h3 {
    font-size: 1rem;
    color: #f9c74f;
    margin-bottom: 10px;
    text-align: center;
}

#ranking-list {
    list-style: none;
    width: 100%;
}

#ranking-list li {
    background: #16213e;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.9rem;
    color: #ccc;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

#ranking-list li.rank-first {
    background: rgba(249, 199, 79, 0.15);
    color: #f9c74f;
    font-weight: bold;
    border: 1px solid rgba(249, 199, 79, 0.3);
}

#ranking-list li.rank-empty {
    color: #666;
    justify-content: center;
    font-style: italic;
}

/* ---- Game screen ---- */
#game-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 420px;
}

.game-header {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    min-height: 48px;
}

.game-logo {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    max-height: 40px;
    width: auto;
    display: block;
}

.game-logo-small {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.logo-img-small {
    max-height: 40px;
    width: auto;
    display: block;
}

.game-header h1 {
    margin-bottom: 0;
}

/* ---- Info bar ---- */
.info-bar {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
    width: 100%;
    max-width: 420px;
}

.info-item {
    background: #16213e;
    border-radius: 10px;
    padding: 8px 16px;
    text-align: center;
    flex: 1;
    min-width: 80px;
}

.info-label {
    font-size: 0.7rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-value {
    font-size: 1.4rem;
    font-weight: bold;
    color: #fff;
}

.timer-value.danger {
    color: #f94144;
    animation: pulse 0.5s infinite alternate;
}

@keyframes pulse {
    from { transform: scale(1); }
    to   { transform: scale(1.15); }
}

/* ---- Grid ---- */
#grid-wrapper {
    width: 100%;
    max-width: 420px;
    aspect-ratio: 1 / 1;
    margin-bottom: 12px;
}

#grid {
    display: grid;
    width: 100%;
    height: 100%;
    gap: 4px;
}

.cell {
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.1s;
    position: relative;
    overflow: visible;
}

.cell:active {
    transform: scale(0.92);
}

.cell.correct {
    outline: 4px solid #06d6a0;
    animation: pop 0.4s ease;
}

.cell.wrong {
    outline: 4px solid #f94144;
    animation: shake 0.3s ease;
}

.cell.burst {
    animation: burst-scale 0.4s ease;
}

@keyframes pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.25); }
    70%  { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes burst-scale {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.3); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%   { transform: translateX(0); }
    25%  { transform: translateX(-6px); }
    75%  { transform: translateX(6px); }
    100% { transform: translateX(0); }
}

/* ---- Burst particles ---- */
.burst-particle {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: burst-fly 0.55s ease-out forwards;
    pointer-events: none;
    z-index: 10;
}

@keyframes burst-fly {
    0%   { transform: translate(-50%, -50%) rotate(var(--angle)) translateY(0) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-40px) scale(0); opacity: 0; }
}

/* ---- Chance message ---- */
.chance-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(249, 199, 79, 0.95);
    color: #1a1a2e;
    font-size: 1.6rem;
    font-weight: bold;
    padding: 16px 36px;
    border-radius: 16px;
    z-index: 200;
    pointer-events: none;
    animation: chance-pop 0.3s ease;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

@keyframes chance-pop {
    0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ---- Buttons ---- */
.btn {
    display: block;
    width: 100%;
    max-width: 420px;
    padding: 14px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: #f9c74f;
    color: #1a1a2e;
    margin-bottom: 12px;
    transition: opacity 0.15s, transform 0.1s;
}

.btn.btn-secondary {
    background: #4a4a8e;
    color: #fff;
    margin-bottom: 32px;
}

.btn:active {
    opacity: 0.85;
    transform: scale(0.97);
}

.course-select {
    width: 100%;
    max-width: 420px;
}

/* ---- Result screen ---- */
#result-screen {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
}

#result-screen.hidden {
    display: none;
}

.result-box {
    background: #16213e;
    border-radius: 18px;
    padding: 28px 32px;
    text-align: center;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.result-box h2 {
    font-size: 1.6rem;
    margin-bottom: 16px;
    color: #f9c74f;
}

.result-stat {
    font-size: 1rem;
    margin-bottom: 6px;
    color: #ccc;
}

.result-stat span {
    font-size: 2rem;
    font-weight: bold;
    color: #fff;
    display: block;
}

