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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f0;
    color: #222;
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.subtitle {
    color: #666;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Cards */
.card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.card p {
    color: #666;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* Forms */
input[type="text"],
input[type="password"] {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    background: #fafafa;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: #888;
    background: #fff;
}

.code-input {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 1.4rem !important;
    text-align: center;
    letter-spacing: 0.3em;
    max-width: 140px;
}

input[type="file"] {
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.form-row label {
    flex: 1;
    font-size: 0.8rem;
    color: #555;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
    background: #f0f0f0;
    border-color: #999;
}

.btn-primary {
    background: #222;
    color: #fff;
    border-color: #222;
}

.btn-primary:hover {
    background: #444;
    border-color: #444;
}

.btn-danger {
    color: #c33;
    border-color: #c33;
}

.btn-danger:hover {
    background: #c33;
    color: #fff;
}

.btn-small {
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
}

.btn-large {
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

/* Home layout */
.home-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 560px) {
    .home-actions {
        flex-direction: row;
    }
    .home-actions .card {
        flex: 1;
    }
}

/* Session header */
.session-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.back-link {
    color: #666;
    text-decoration: none;
    font-size: 0.85rem;
}

.back-link:hover {
    color: #222;
}

.session-code-display {
    font-size: 0.9rem;
    color: #555;
}

.session-code-display strong {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 1.3rem;
    letter-spacing: 0.15em;
    color: #222;
}

/* Lobby */
.hint {
    color: #888;
    font-size: 0.8rem;
    margin-bottom: 1rem;
    text-align: center;
}

.instrument-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.instrument-card-lobby {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
}

.instrument-card-lobby {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.lobby-instrument-img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.lobby-instrument-info {
    margin-bottom: 0.5rem;
}

.lobby-instrument-desc {
    color: #888;
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

.instrument-card-lobby h3 {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.slot-row {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.slot-btn {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fafafa;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.15s;
}

.slot-btn:hover:not([disabled]) {
    border-color: #888;
    background: #f0f0f0;
}

.slot-btn.slot-taken {
    background: #eee;
    color: #999;
    cursor: default;
}

.slot-btn.slot-you {
    background: #222;
    color: #fff;
    border-color: #222;
}

#host-controls {
    text-align: center;
    margin-top: 1rem;
}

/* Playing */
.playing-instrument {
    text-align: center;
    margin-bottom: 2rem;
}

.playing-instrument-img {
    width: 160px;
    height: 160px;
    object-fit: contain;
    border-radius: 10px;
    margin-bottom: 0.75rem;
}

.playing-instrument-desc {
    color: #888;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.playing-instrument h2 {
    font-size: 1.5rem;
}

.playing-slot-label {
    color: #888;
    font-size: 0.85rem;
}

.playing-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

.key-hint {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.key-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 100px;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: #fff;
    transition: all 0.1s;
    user-select: none;
}

.key-box.active {
    background: #222;
    color: #fff;
    border-color: #222;
    transform: scale(0.96);
}

.key-label {
    font-size: 1rem;
    font-weight: 600;
}

.key-desc {
    font-size: 0.7rem;
    color: #888;
    margin-top: 0.25rem;
}

.key-box.active .key-desc {
    color: #aaa;
}

.cooldown-bar-wrap {
    width: 260px;
    height: 4px;
    background: #eee;
    border-radius: 2px;
    overflow: hidden;
}

.cooldown-bar {
    height: 100%;
    background: #222;
    border-radius: 2px;
    width: 100%;
}

/* Roster */
.roster {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
}

.roster h3 {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 0.5rem;
}

.roster ul {
    list-style: none;
}

.roster li {
    padding: 0.3rem 0;
    font-size: 0.85rem;
    color: #555;
    border-bottom: 1px solid #f0f0f0;
}

.roster li:last-child {
    border-bottom: none;
}

.roster li.roster-you {
    color: #222;
    font-weight: 600;
}

/* Free Play */
.freeplay-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.freeplay-nav-btn {
    width: 52px;
    height: 52px;
    border: 2px solid #ddd;
    border-radius: 50%;
    background: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: #222;
    transition: all 0.15s;
    flex-shrink: 0;
}

.freeplay-nav-btn:hover {
    background: #222;
    color: #fff;
    border-color: #222;
}

.freeplay-center {
    text-align: center;
    min-width: 0;
}

.freeplay-img {
    width: 180px;
    height: 180px;
    object-fit: contain;
    border-radius: 10px;
    margin-bottom: 0.75rem;
}

.freeplay-center h2 {
    font-size: 1.5rem;
}

.freeplay-desc {
    color: #888;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Admin */
.instrument-card {
    margin-bottom: 1rem;
}

.instrument-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.instrument-card-header h3 {
    font-size: 1rem;
}

.admin-instrument-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 6px;
}

.admin-instrument-desc {
    color: #888;
    font-size: 0.75rem;
    margin: 0;
}

.sound-info {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.75rem;
}

.sound-info div {
    margin-bottom: 0.4rem;
}

.sound-info audio {
    height: 28px;
    vertical-align: middle;
}

.duration {
    font-size: 0.75rem;
    color: #999;
    margin-left: 0.5rem;
}

.update-form {
    border-top: 1px solid #eee;
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}
