@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

:root {
    --page-bg: #f4f4f4;
    --surface: rgba(255, 255, 255, 0.96);
    --surface-solid: #ffffff;
    --text: #222222;
    --muted: #666666;
    --border: #e7e7e7;
    --primary: #222222;
    --danger: #b3261e;
    --danger-soft: #fde0de;
    --success: #167c2c;
    --success-soft: #dff3e3;
    --warning: #8a6500;
    --warning-soft: #fff3cd;
    --radius: 14px;
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.07);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: 'Montserrat', Arial, sans-serif;
    color: var(--text);
    background: var(--page-bg);
}

body.quest-background {
    background-image:
        linear-gradient(rgba(244, 244, 244, 0.62), rgba(244, 244, 244, 0.62)),
        var(--quest-background);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

body.modal-open {
    overflow: hidden;
}

button,
input,
textarea,
select {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.container {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 16px;
}

.container-wide {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 16px;
}

.card,
.header,
.notice,
.waiting {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h1,
h2,
h3 {
    margin-top: 0;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 22px;
}

h3 {
    font-size: 18px;
}

.muted,
.hint {
    color: var(--muted);
}

.hint {
    font-size: 13px;
    line-height: 1.45;
}

.back-link {
    display: inline-block;
    margin-bottom: 16px;
    color: #333;
    text-decoration: none;
    font-weight: 600;
}

label {
    display: block;
    margin: 16px 0 7px;
    font-weight: 600;
}

input,
textarea,
select {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid #cccccc;
    border-radius: 10px;
    background: #ffffff;
    color: var(--text);
    font-size: 16px;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid rgba(34, 34, 34, 0.14);
    border-color: #777777;
}

.action-button,
.primary-button,
.secondary-button,
.danger-button,
button {
    display: block;
    width: 100%;
    padding: 13px 15px;
    border: 0;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.action-button,
.primary-button,
button {
    background: var(--primary);
    color: #ffffff;
}

.secondary-button {
    background: #e9e9e9;
    color: var(--text);
}

.danger-button {
    background: var(--danger);
    color: #ffffff;
}

button:disabled {
    opacity: 0.45;
    cursor: default;
}

.stack-actions {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.inline-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}

.riddle-number-badge {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #ffffff;
    font-weight: 700;
    line-height: 1;
}

.reference-photo,
.background-preview,
.attempt-photo {
    display: block;
    width: 100%;
    border-radius: 12px;
    background: #eeeeee;
    object-fit: contain;
}

.background-preview {
    max-height: 280px;
    margin: 12px 0;
    object-fit: cover;
}

.reference-photo,
.attempt-photo {
    max-height: 360px;
    margin-top: 10px;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    padding: 16px;
    background: rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 430px;
    max-height: 95vh;
    overflow-y: auto;
    background: #ffffff;
    border-radius: 16px;
    padding: 18px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.modal-header h2 {
    margin: 0;
}

.close-button {
    width: auto;
    margin: 0;
    padding: 4px 10px;
    background: transparent;
    color: #333333;
    font-size: 28px;
}

@media (max-width: 560px) {
    .inline-actions {
        grid-template-columns: 1fr;
    }
}
