@import url("https://fonts.googleapis.com/css2?family=Klee+One:wght@400;600&display=swap");

:root {
    --paper-color: #e5d1ad;
    --paper-shade: linear-gradient(rgba(255, 248, 226, 0.24), rgba(120, 84, 45, 0.1));
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: "Klee One", "Hannotate SC", "Yuji Syuku", "Comic Sans MS", cursive;
    background-color: #6f563e;
    background-image: linear-gradient(rgba(40, 25, 12, 0.18), rgba(40, 25, 12, 0.18)), url("board.jpg");
    background-position: center;
    background-size: cover;
    background-attachment: fixed;
    color: #493b2c;
    display: block;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

body.survey-mode {
    background: #c9c0b4;
}

body.survey-mode::before {
    background: rgba(48, 37, 28, 0.025);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: rgba(24, 15, 8, 0.08);
}

.home-screen {
    display: grid;
    min-height: calc(100vh - 40px);
    place-items: center;
}

.home-paper {
    position: relative;
    width: min(620px, 100%);
    padding: clamp(42px, 8vw, 78px) clamp(28px, 8vw, 76px);
    background-color: var(--paper-color);
    background-image: var(--paper-shade);
    border: 1px solid rgba(95, 67, 38, 0.4);
    box-shadow: 0 12px 28px rgba(24, 15, 8, 0.42), 0 2px 4px rgba(24, 15, 8, 0.25);
    transform: rotate(-1deg);
    text-align: center;
}

.home-paper::before,
.home-paper::after {
    content: "";
    position: absolute;
    width: 70px;
    height: 18px;
    background: rgba(238, 224, 185, 0.68);
    box-shadow: 0 1px 2px rgba(60, 40, 20, 0.15);
}

.home-paper::before {
    top: -8px;
    left: 18%;
    transform: rotate(-8deg);
}

.home-paper::after {
    right: 15%;
    bottom: -7px;
    transform: rotate(7deg);
}

.home-eyebrow {
    margin-bottom: 14px;
    color: #765338;
    font-size: 0.95rem;
    font-weight: bold;
    letter-spacing: 0.16em;
}

.home-paper h1 {
    margin-bottom: 26px;
    border-bottom: 2px solid #876443;
    font-size: clamp(2.2rem, 7vw, 3.8rem);
    letter-spacing: 0.18em;
}

.home-description {
    margin: 0 auto 34px;
    max-width: 440px;
    font-size: clamp(1rem, 2.4vw, 1.2rem);
    font-weight: bold;
    line-height: 2;
}

.start-btn,
.home-results-btn {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.start-btn {
    padding: 15px;
    background: #765338;
    color: #fff;
    font-size: 1.1rem;
}

.start-btn:hover {
    background: #5e402b;
}

.home-results-btn {
    margin-top: 16px;
    padding: 10px;
    background: transparent;
    color: #765338;
    text-decoration: underline;
}

.home-results-btn:hover {
    background: rgba(118, 83, 56, 0.1);
}

.music-toggle-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1;
    padding: 10px 16px;
    border: 1px solid #765338;
    border-radius: 4px;
    background: rgba(229, 209, 173, 0.92);
    box-shadow: 0 2px 6px rgba(49, 31, 16, 0.25);
    color: #765338;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: bold;
}

.utility-controls {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.translate-btn,
.language-select {
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid #765338;
    border-radius: 4px;
    background: rgba(229, 209, 173, 0.96);
    box-shadow: 0 2px 6px rgba(49, 31, 16, 0.25);
    color: #765338;
    cursor: pointer;
    font-weight: bold;
}

.language-select {
    font-weight: normal;
}

.utility-controls .music-toggle-btn {
    position: static;
}

.music-toggle-btn:hover {
    background: #e5d1ad;
}

[hidden] {
    display: none !important;
}

.back-home-btn {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 5;
    display: none;
    padding: 10px 16px;
    border: 1px solid #765338;
    border-radius: 4px;
    background: rgba(229, 209, 173, 0.96);
    box-shadow: 0 2px 6px rgba(49, 31, 16, 0.25);
    color: #765338;
    cursor: pointer;
    font-weight: bold;
}

body.survey-mode .back-home-btn {
    display: block;
}

.back-home-btn:hover {
    background: #e5d1ad;
}

.password-modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(49, 31, 16, 0.6);
    z-index: 20;
}

.password-modal[hidden] {
    display: none;
}

.password-dialog {
    position: relative;
    display: grid;
    gap: 8px;
    width: min(420px, 100%);
    padding: 28px;
    background: #e5d1ad;
    border: 1px solid #876443;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.password-dialog h2 {
    margin-bottom: 12px;
    color: #4b3825;
}

.password-dialog input {
    width: 100%;
    min-height: 48px;
    margin: 0 0 8px;
    padding: 12px;
    font-size: 1.15rem;
    letter-spacing: 0.08em;
}

.password-dialog-close {
    position: absolute;
    top: 8px;
    right: 12px;
    border: 0;
    background: transparent;
    color: #493b2c;
    font-size: 1.6rem;
    cursor: pointer;
}

.password-message {
    min-height: 1.4em;
    color: #9b3d34;
}

.password-dialog-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.password-dialog-actions button {
    flex: 1;
    padding: 11px;
    border: 0;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
}

.password-cancel {
    background: #c9b99d;
    color: #493b2c;
}

.password-submit {
    background: #765338;
    color: white;
}

.confirm-modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(49, 31, 16, 0.6);
    z-index: 30;
}

.confirm-modal[hidden] {
    display: none;
}

.confirm-dialog {
    position: relative;
    width: min(420px, 100%);
    padding: 28px;
    background: #e5d1ad;
    border: 1px solid #876443;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.confirm-dialog h2 {
    margin-bottom: 16px;
    color: #4b3825;
}

.confirm-dialog-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.confirm-dialog-actions button {
    flex: 1;
    padding: 11px;
    border: 0;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
}

.confirm-cancel {
    background: #c9b99d;
    color: #493b2c;
}

.confirm-submit {
    background: #765338;
    color: white;
}

.submit-loading {
    display: grid;
    justify-items: center;
    gap: 14px;
    margin: 20px 0;
}

.loading-spinner {
    width: 42px;
    height: 42px;
    border: 4px solid rgba(118, 83, 56, 0.25);
    border-top-color: #765338;
    border-radius: 50%;
    animation: submit-spin 0.8s linear infinite;
}

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

#submit-complete {
    margin-top: 20px;
}

#page-close {
    width: 100%;
    margin-top: 8px;
}

.change-password-btn {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 5;
    padding: 8px 16px;
    border: 0;
    border-radius: 4px;
    background: #2c3e50;
    color: white;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.survey-container {
    background-color: var(--paper-color);
    background-image: var(--paper-shade);
    border: 1px solid rgba(95, 67, 38, 0.35);
    border-radius: 3px;
    box-shadow: 0 5px 16px rgba(63, 42, 22, 0.25);
    max-width: 650px;
    width: 100%;
    margin: 20px auto;
    padding: 30px;
}

#survey-container {
    max-width: 860px;
    margin: 34px auto;
    padding: clamp(36px, 5vw, 58px);
    font-family: "Klee One", "Hannotate SC", "Yuji Syuku", "Comic Sans MS", cursive;
}

#survey-container input,
#survey-container textarea,
#survey-container button {
    font-family: inherit;
}

#survey-container h1 {
    font-size: clamp(1.7rem, 3.2vw, 2.2rem);
    margin-bottom: 34px;
    padding-bottom: 14px;
}

#survey-container .question-group {
    margin-bottom: 32px;
}

#survey-container .question-label {
    margin-bottom: 15px;
    font-size: clamp(1.05rem, 2vw, 1.2rem);
    line-height: 1.7;
}

#survey-container .options label {
    margin-bottom: 11px;
    font-size: 1.08rem;
}

#survey-container .options input[type="radio"],
#survey-container .options input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    vertical-align: -3px;
}

#survey-container input[type="text"],
#survey-container textarea {
    min-height: 52px;
    padding: 13px 52px 13px 14px;
    font-size: 1.08rem;
}

#survey-container textarea {
    min-height: 130px;
}

#survey-container .submit-btn {
    padding: 17px;
    font-size: 1.15rem;
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    text-align: center;
    color: #4b3825;
    border-bottom: 2px solid #876443;
    padding-bottom: 10px;
}

.question-group {
    margin-bottom: 24px;
}

.question-label {
    display: block;
    font-weight: bold;
    margin-bottom: 12px;
    font-size: 1rem;
    line-height: 1.5;
}

.required-mark {
    color: #8b3f2f;
    font-weight: bold;
    white-space: nowrap;
}

.anonymous-note {
    color: #765338;
    font-size: 0.85em;
    font-weight: normal;
}

.options label {
    display: block;
    margin-bottom: 8px;
    cursor: pointer;
}

.options input[type="radio"],
.options input[type="checkbox"] {
    margin-right: 8px;
}

input[type="text"],
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ad8f68;
    border-radius: 2px;
    background-color: rgba(255, 248, 229, 0.55);
    font-size: 0.95rem;
    margin-top: 6px;
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: #876443;
}

textarea {
    resize: vertical;
}

.voice-input-wrapper {
    position: relative;
    width: 100%;
}

.voice-input-wrapper input[type="text"],
.voice-input-wrapper textarea {
    margin-top: 6px;
}

.voice-input-btn {
    position: absolute;
    top: 50%;
    right: 10px;
    z-index: 1;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid #ad8f68;
    border-radius: 50%;
    background: rgba(255, 248, 229, 0.9);
    color: #765338;
    cursor: pointer;
    line-height: 1;
    transform: translateY(-50%);
}

.voice-input-btn svg {
    display: block;
    width: 19px;
    height: 19px;
    margin: auto;
    fill: currentColor;
}

.voice-input-wrapper textarea + .voice-input-btn {
    top: 26px;
}

.voice-input-btn:hover,
.voice-input-btn.is-listening {
    background: #765338;
    color: white;
}

.voice-input-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.submit-btn {
    width: 100%;
    background-color: #765338;
    color: white;
    border: none;
    padding: 14px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-top: 10px;
}

.submit-btn:hover {
    background-color: #5e402b;
}