:root {
    --bg-gradient: linear-gradient(to bottom, #8b5a2b, #5c3a21); /* Wooden base */
    --primary-color: #f39c12; /* Yellow chalk */
    --primary-hover: #e67e22;
    --secondary-color: #ecf0f1; /* White chalk / Paper border */
    --secondary-hover: #bdc3c7;
    --danger-color: #e74c3c; /* Red chalk */
    --danger-hover: #c0392b;
    --text-main: #ffffff; /* Chalk text */
    --text-light: #a5b1c2;
    --text-highlight: #f1c40f;
    --card-bg: #1b4f2c; /* Chalkboard green */
    --card-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
    --paper-line: #27ae60;
}

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

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: #6e4726;
    background-image: 
        repeating-linear-gradient(90deg, transparent, transparent 98px, rgba(0,0,0,0.3) 98px, rgba(0,0,0,0.3) 100px),
        var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-main);
}

.container {
    width: 100%;
    max-width: 700px;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 40px;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.5), var(--card-shadow);
    border: 16px solid #8e5e3c; /* Wooden frame */
    min-height: 600px;
    position: relative;
    overflow: hidden;
    margin: 20px;
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    animation: fadeIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.phase-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.4s ease-out;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.title-logo {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: transparent;
    border: none;
    box-shadow: none;
}

.sub-title-logo {
    color: #fff;
    font-size: 1rem;
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

.game-title {
    font-size: 2.2rem;
    font-weight: 900;
    color: #fff;
    line-height: 1.2;
    text-shadow: 2px 2px 0 var(--primary-hover);
}

.subtitle {
    font-size: 1rem;
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 40px;
    text-align: center;
}

.screen-heading {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 25px;
    color: var(--secondary-color);
    text-align: center;
    position: relative;
}

.screen-heading::after {
    content: '';
    display: block;
    width: 50px;
    height: 4px;
    background: var(--primary-color);
    margin: 8px auto 0;
    border-radius: 2px;
}

.phase-heading {
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 10px;
    text-align: center;
    color: var(--secondary-color);
}

.phase-desc {
    text-align: center;
    font-size: 0.95rem;
    margin-bottom: 20px;
    color: var(--text-light);
    font-weight: bold;
}

.text-danger { color: var(--danger-color); }
.text-highlight { color: var(--text-highlight); }
.text-center { text-align: center; }

/* Inputs */
.input-group {
    width: 100%;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-size: 0.9rem;
    font-weight: bold;
}

.input-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.btn-random {
    background: #f1f2f6;
    border: 1px solid #d1d8e0;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-random:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-hover);
}

.input-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #d1d8e0;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    outline: none;
    background: #f8f9fa;
}

.input-group input:focus {
    border-color: var(--primary-color);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(243, 156, 18, 0.2);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-lg {
    padding: 16px 20px;
    font-size: 1.1rem;
}

.primary-btn {
    background-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 6px 0 var(--primary-hover);
}

.primary-btn:hover {
    transform: translateY(2px);
    box-shadow: 0 4px 0 var(--primary-hover);
}

.primary-btn:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 var(--primary-hover);
}

.secondary-btn {
    background-color: var(--secondary-color);
    color: #333;
    box-shadow: 0 6px 0 var(--secondary-hover);
}

.secondary-btn:hover {
    transform: translateY(2px);
    box-shadow: 0 4px 0 var(--secondary-hover);
}

.secondary-btn:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 var(--secondary-hover);
}

.danger-btn {
    background-color: var(--danger-color);
    color: white;
    box-shadow: 0 6px 0 var(--danger-hover);
}
.danger-btn:hover {
    transform: translateY(2px);
    box-shadow: 0 4px 0 var(--danger-hover);
}
.danger-btn:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 var(--danger-hover);
}

.text-btn {
    background: transparent;
    color: var(--text-light);
    box-shadow: none;
    text-decoration: underline;
}
.text-btn:hover {
    color: var(--text-main);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: translateY(6px);
    box-shadow: 0 0 0 transparent;
}

.pulse-animation {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(247, 183, 49, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(247, 183, 49, 0); }
    100% { box-shadow: 0 0 0 0 rgba(247, 183, 49, 0); }
}

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mb-2 { margin-bottom: 20px; }

/* Lobby & Cards */
.card, .form-card {
    background: #fff;
    color: #333;
    border-radius: 12px;
    padding: 20px;
    border: 2px solid #f1f2f6;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.room-info-card {
    background: #fffdf5;
    color: #333;
    padding: 15px;
    border-radius: 2px;
    text-align: center;
    margin: 0 auto 30px auto;
    max-width: 80%;
    border: 1px solid #e0d8c3;
    font-weight: bold;
    font-size: 1.3rem;
    box-shadow: 3px 3px 12px rgba(0,0,0,0.4);
    position: relative;
    transform: rotate(-1deg);
}

.room-info-card::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%) rotate(3deg);
    width: 60px;
    height: 25px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.room-id-large {
    font-size: 1.8rem;
    color: var(--danger-color);
    letter-spacing: 4px;
}

.selectable { user-select: text; }

.players-container {
    width: 100%;
    margin-bottom: 25px;
}

.players-container h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--secondary-color);
    text-align: center;
}

.player-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    list-style: none;
}

.player-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: #fff79a;
    border-radius: 0 0 15px 0 / 0 0 5px 0;
    font-weight: bold;
    color: #333;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    border: none;
    transform: rotate(-1deg);
}

.player-item:nth-child(even) {
    background: #ffb8b8;
    transform: rotate(1deg);
}

.player-item:nth-child(3n) {
    background: #b8ffd1;
    transform: rotate(-0.5deg);
}

.player-item.ready {
    background: #e8f8f5;
    border-bottom-color: var(--text-highlight);
    color: var(--text-highlight);
}

.host-badge {
    background: var(--primary-color);
    color: #fff;
    font-size: 0.7rem;
    padding: 3px 6px;
    border-radius: 6px;
    margin-left: 5px;
}

.waiting-msg {
    text-align: center;
    color: var(--text-light);
    font-weight: bold;
    margin-bottom: 15px;
}

/* Settings Box */
.settings-box {
    background: #fff;
    color: #333;
    border-radius: 4px;
    padding: 20px;
    text-align: left;
    box-shadow: 3px 3px 15px rgba(0,0,0,0.4);
    background-image: repeating-linear-gradient(transparent, transparent 31px, var(--paper-line) 31px, var(--paper-line) 32px);
    background-position: 0 35px;
    border: 1px solid #d1d8e0;
    position: relative;
    margin-bottom: 20px;
}

.settings-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20px;
    bottom: 0;
    width: 2px;
    background: rgba(235, 59, 90, 0.3);
}

.settings-box h3 {
    margin-top: 0;
    margin-bottom: 15px;
    margin-left: 20px;
    font-size: 1.2rem;
    color: #333;
    background: #fff;
    display: inline-block;
    padding: 0 5px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    margin-left: 20px;
    font-size: 0.95rem;
    font-weight: bold;
}

.setting-item input {
    width: 60px;
    padding: 5px;
    border: 1px solid #d1d8e0;
    border-radius: 5px;
    text-align: center;
}

/* Waiting / Generating */
.waiting-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: rgba(255,255,255,0.8);
    color: #333;
    border-radius: 12px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0,0,0,0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.spinner.large {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Progress Bar */
.progress-container {
    width: 80%;
    margin: 0 auto;
    height: 12px;
    background: #dfe4ea;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: var(--primary-color);
    border-radius: 10px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(247, 183, 49, 0.5);
}

/* Flavor Text */
.flavor-text {
    font-size: 0.95rem;
    color: var(--text-light);
    min-height: 40px;
    margin-top: 20px;
    font-style: italic;
    transition: opacity 0.5s ease-in-out;
}

.fade-out {
    opacity: 0;
}

/* Memorize Phase */
.timer-header {
    text-align: center;
    margin-bottom: 20px;
}

.timer-box {
    font-size: 3rem;
    font-weight: 900;
    color: var(--danger-color);
    text-shadow: 2px 2px 0px rgba(235, 59, 90, 0.2);
}

.events-scroll-container {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.event-card {
    background: #fff;
    color: #333;
    border-left: 6px solid var(--primary-color);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.event-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--danger-color);
    margin-bottom: 10px;
    border-bottom: 1px dashed #d1d8e0;
    padding-bottom: 5px;
}

.event-sentence {
    font-size: 1.1rem;
    line-height: 1.8;
    font-weight: bold;
    color: #333;
    padding: 5px;
}

.word-highlight {
    color: var(--danger-color);
    font-weight: 900;
    text-decoration: underline;
    text-decoration-color: rgba(235, 59, 90, 0.3);
    text-underline-offset: 4px;
}

.event-detail {
    font-size: 0.95rem;
    margin-bottom: 5px;
    line-height: 1.4;
}

.event-detail span.label {
    display: inline-block;
    width: 80px;
    font-weight: bold;
    color: var(--secondary-color);
}

/* Test Phase - Test Paper Theme */
.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 15px;
}

.test-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--secondary-color);
}

.test-paper {
    background: #fff;
    color: #333;
    width: 100%;
    border-radius: 4px;
    box-shadow: 0 2px 15px rgba(0,0,0,0.1);
    position: relative;
    padding: 30px 20px;
    background-image: repeating-linear-gradient(transparent, transparent 31px, var(--paper-line) 31px, var(--paper-line) 32px);
    background-position: 0 30px;
    min-height: 300px;
    border: 1px solid #d1d8e0;
}

.test-paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 40px;
    bottom: 0;
    width: 2px;
    background: rgba(235, 59, 90, 0.3);
}

.test-paper-header {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 20px;
    color: #333;
    background: #fff;
    display: inline-block;
    padding: 0 10px;
    margin-left: 30px;
}

.test-paper-content {
    margin-left: 30px;
    line-height: 32px;
    font-size: 1.1rem;
    font-weight: bold;
}

.test-text {
    display: inline;
    line-height: 32px;
}

.test-blank {
    display: inline-block;
    min-width: 100px;
    height: 28px;
    border-bottom: 2px solid var(--text-main);
    margin: 0 5px;
    text-align: center;
    color: var(--primary-color);
    font-weight: 900;
    cursor: pointer;
    vertical-align: baseline;
    transition: all 0.2s;
    background: rgba(247, 183, 49, 0.1);
}

.test-blank:hover {
    background: rgba(247, 183, 49, 0.3);
}

.test-blank.filled {
    border-bottom-color: var(--primary-color);
    color: var(--danger-color);
}

/* Modal for Choices */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #fff;
    color: #333;
    width: 90%;
    max-width: 400px;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-content h3 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

.choices-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal .text-btn {
    color: #555;
}

.modal .text-btn:hover {
    color: #111;
}

.choice-btn {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #d1d8e0;
    padding: 15px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.choice-btn:hover {
    border-color: var(--primary-color);
    background: rgba(247, 183, 49, 0.1);
    transform: translateX(5px);
}

/* Scoreboard */
.qr-card {
    text-align: center;
}

.correct-ans {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--danger-color);
    margin: 15px 0;
}

.score-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: #fff;
    color: #333;
    border-radius: 8px;
    margin-bottom: 8px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 150px;
    margin: 30px 0;
    gap: 10px;
}

.podium-step {
    width: 80px;
    background: var(--primary-color);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    border-radius: 8px 8px 0 0;
    color: #fff;
    font-weight: 900;
    padding-top: 10px;
    box-shadow: inset 0 -10px 20px rgba(0,0,0,0.1);
}

.podium-step.rank-1 { height: 100%; background: #f1c40f; }
.podium-step.rank-2 { height: 70%; background: #bdc3c7; }
.podium-step.rank-3 { height: 50%; background: #cd7f32; }

.podium-name {
    margin-top: -30px;
    color: #333;
    font-size: 0.9rem;
    background: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* All Events Result View */
.all-events-container {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.result-event-card {
    background: #fffdf5; /* slightly yellow paper-like */
    color: #333;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #ddd;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    position: relative;
    text-align: left;
}

.result-event-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--danger-color);
    margin-bottom: 10px;
    border-bottom: 2px dashed #ccc;
    padding-bottom: 5px;
}

.result-event-body {
    font-size: 1rem;
    line-height: 1.8;
}

.result-word {
    font-weight: bold;
    color: #111;
    text-decoration: underline;
    text-decoration-color: #aaa;
}

.author-tag {
    font-size: 0.75rem;
    color: #555;
    background: #e0e0e0;
    padding: 2px 6px;
    border-radius: 12px;
    margin-left: 4px;
    margin-right: 8px;
    vertical-align: middle;
    font-weight: normal;
}

/* Icon Selector */
.icon-item {
    font-size: 1.5rem;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    background: #f1f2f6;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.icon-item:hover {
    background: #fff;
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.icon-item.selected {
    background: rgba(247, 183, 49, 0.2);
    border-color: var(--primary-color);
}

