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

html {
    background-color: #2a1810;
}

body {
    font-family: serif;
    min-height: 100vh;
    display: block;
    padding: clamp(12px, 5vw, 20px);
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.book-shell {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    position: relative;
}

.book-container {
    width: 100%;
    max-width: 800px;
    background: linear-gradient(145deg, #f4e4bc, #e8d4a0);
    border-radius: 0 0 15px 15px;
    box-shadow:
        inset 0 0 120px rgba(139, 69, 19, 0.2),
        inset 0 0 40px rgba(101, 67, 33, 0.1);
    position: relative;
    overflow: hidden;
    border: 3px solid #8b4513;
    border-top: none;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.book-tabs {
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    margin: 0 auto -1px;
    background: rgba(60, 32, 16, 0.35);
    padding: clamp(6px, 1.5vw, 12px) 0 0;
    border-radius: 18px 18px 0 0;
    width: 100%;
    max-width: 800px;
}

.book-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(10px, 2.8vw, 16px);
    background: linear-gradient(165deg, rgba(118, 68, 29, 0.92), rgba(78, 42, 18, 0.95));
    color: #f4e4bc;
    text-decoration: none;
    border: 3px solid #8b4513;
    border-bottom: none;
    border-radius: 18px 18px 0 0;
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.25),
        inset 0 0 18px rgba(0, 0, 0, 0.18);
    font-family: 'Noto Serif JP', serif;
    font-size: clamp(1em, 2.4vw, 1.2em);
    letter-spacing: 0.06em;
    transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.book-tab + .book-tab {
    border-left: none;
}

.book-tab:first-child {
    border-top-left-radius: 18px;
}

.book-tab:last-child {
    border-top-right-radius: 18px;
}

.book-tab.is-active {
    background: linear-gradient(150deg, rgba(248, 235, 201, 0.98), rgba(232, 205, 159, 0.95));
    color: #3b2414;
    border: 3px solid #8b4513;
    border-bottom: none;
    box-shadow:
        inset 0 0 40px rgba(139, 69, 19, 0.18),
        inset 0 0 16px rgba(101, 67, 33, 0.16);
}

.book-tab.is-active:hover {
    background: linear-gradient(150deg, rgba(251, 242, 213, 0.99), rgba(238, 220, 178, 0.97));
}

.book-tab:focus-visible {
    outline: 3px solid rgba(244, 228, 188, 0.85);
    outline-offset: 3px;
}

.book-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    right: -50%;
    bottom: -50%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><filter id="noise"><feTurbulence baseFrequency="0.9" numOctaves="4" /></filter><rect width="100" height="100" filter="url(%23noise)" opacity="0.02"/></svg>');
    opacity: 0.4;
    pointer-events: none;
}

.page-border {
    padding: clamp(16px, 4.5vw, 30px);
    background: linear-gradient(to bottom, rgba(139, 69, 19, 0.05), transparent 20%, transparent 80%, rgba(139, 69, 19, 0.05));
    position: relative;
}

.page-border::after {
    content: '';
    position: absolute;
    top: clamp(14px, 4vw, 22px);
    left: clamp(14px, 4vw, 22px);
    right: clamp(14px, 4vw, 22px);
    bottom: clamp(14px, 4vw, 22px);
    border: 2px solid rgba(139, 69, 19, 0.3);
    border-radius: 8px;
    pointer-events: none;
}

h1 {
    text-align: center;
    color: #4a2c17;
    font-size: clamp(1.6em, 5vw, 2.5em);
    margin-bottom: clamp(18px, 5vw, 30px);
    text-shadow:
        2px 2px 4px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(139, 69, 19, 0.2);
    font-weight: 700;
    letter-spacing: 2px;
    position: relative;
}

h1::after {
    content: '⟦ ❦ ⟧';
    display: block;
    font-size: 0.5em;
    margin-top: 10px;
    color: #8b4513;
    opacity: 0.6;
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: clamp(10px, 3vw, 15px);
    margin-bottom: clamp(18px, 4vw, 30px);
    padding: clamp(12px, 4vw, 20px);
    background: rgba(139, 69, 19, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(139, 69, 19, 0.3);
}

.stat {
    text-align: center;
    padding: clamp(6px, 2vw, 10px);
    background: linear-gradient(145deg, rgba(244, 228, 188, 0.5), rgba(232, 212, 160, 0.5));
    border-radius: 5px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-label {
    font-size: 0.9em;
    color: #6b4423;
    margin-bottom: 5px;
    font-weight: bold;
}

.stat-value {
    font-size: 1.4em;
    color: #4a2c17;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.story-text {
    color: #3a2317;
    line-height: 1.8;
    margin-bottom: clamp(18px, 5vw, 30px);
    padding: clamp(14px, 5vw, 25px);
    background: linear-gradient(to bottom, transparent, rgba(139, 69, 19, 0.03));
    border-radius: 5px;
    font-size: clamp(1em, 3vw, 1.1em);
    position: relative;
    min-height: clamp(160px, 45vh, 220px);
    white-space: pre-line;
}

.choices-container {
    margin-top: 30px;
    padding: 0 clamp(12px, 4.5vw, 18px);
}


/* タッチデバイスでのタップ領域を拡大 */
.choice-button {
    display: block;
    width: 100%;
    padding: clamp(12px, 4vw, 15px) clamp(16px, 5vw, 25px);
    margin-bottom: clamp(10px, 3vw, 15px);
    background: linear-gradient(145deg, #8b4513, #6b3410);
    color: #f4e4bc;
    border: 2px solid #5a2d0f;
    border-radius: 8px;
    font-size: clamp(0.95em, 2.8vw, 1.05em);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-family: 'Noto Serif JP', serif;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    text-decoration: none;
    min-height: 44px; /* iOS推奨の最小タップ領域 */
}

.choices-container form {
    display: block;
    width: 100%;
    margin: 0;
}

.choice-button::before {
    content: '▸';
    margin-right: 10px;
    font-size: 1.2em;
    transition: transform 0.3s ease;
    display: inline-block;
}

.choice-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(244, 228, 188, 0.2), transparent);
    transform: translateY(-50%);
    transition: left 0.5s ease;
}

.choice-button:hover {
    background: linear-gradient(145deg, #a05016, #8b4513);
}

.choice-button:hover::after {
    left: 100%;
}

.choice-button:active {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.inventory {
    margin-top: clamp(18px, 5vw, 30px);
    padding: clamp(12px, 4vw, 18px);
    background: rgba(139, 69, 19, 0.08);
    border-radius: 5px;
    border: 1px solid rgba(139, 69, 19, 0.2);
}

.inventory-title {
    font-size: 1.1em;
    color: #6b4423;
    margin-bottom: 10px;
    font-weight: bold;
}

.inventory-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: clamp(8px, 3vw, 15px);
}

.inventory-item {
    padding: 5px 12px;
    background: linear-gradient(145deg, rgba(244, 228, 188, 0.7), rgba(232, 212, 160, 0.7));
    border: 1px solid rgba(139, 69, 19, 0.3);
    border-radius: 4px;
    font-size: 0.9em;
    color: #4a2c17;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.page-number {
    text-align: center;
    margin-top: clamp(20px, 5vw, 30px);
    color: #8b4513;
    font-size: 0.9em;
    opacity: 0.7;
}

.validation-overlay {
    position: fixed;
    top: 10px;
    right: 10px;
    padding: 10px;
    border-radius: 5px;
    font-size: 12px;
    max-width: 300px;
    z-index: 1000;
}

.validation-valid {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.validation-invalid {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Paragraph Log Styles */
.paragraph-log__summary {
    margin: clamp(10px, 3vw, 18px) 0;
    text-align: center;
    color: #4a2c17;
    font-weight: 600;
}

.paragraph-log__empty {
    padding: clamp(12px, 3vw, 18px);
    text-align: center;
    color: #5a3419;
    background: rgba(244, 228, 188, 0.6);
    border: 1px dashed rgba(90, 52, 25, 0.4);
    border-radius: 10px;
}

.paragraph-log {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 2vw, 14px);
    margin: 0;
    padding: 0;
}

.paragraph-log__item {
    padding: clamp(12px, 3vw, 18px);
    border-radius: 10px;
    border: 1px solid rgba(139, 69, 19, 0.25);
    background: linear-gradient(145deg, rgba(244, 228, 188, 0.7), rgba(232, 212, 160, 0.7));
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.08),
        0 6px 16px rgba(0, 0, 0, 0.12);
    line-height: 1.6;
    color: #4a2c17;
    white-space: pre-line;
}

/* ステータス画面とタイトル画面のスタイル統一 */
.stats-section, .inventory-section {
    margin-bottom: 25px;
}

.stats-section h2, .inventory-section h2 {
    color: #4a2c17;
    margin-bottom: 15px;
    font-size: 1.3em;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(139, 69, 19, 0.3);
}

.inventory-items {
    margin-top: 15px;
}

.inventory-item-detail {
    background: linear-gradient(145deg, rgba(244, 228, 188, 0.6), rgba(232, 212, 160, 0.6));
    padding: clamp(12px, 4vw, 16px);
    border-radius: 8px;
    border: 1px solid rgba(139, 69, 19, 0.2);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.item-name {
    font-weight: bold;
    color: #4a2c17;
    font-size: 1.1em;
    margin-bottom: 5px;
}

.item-quantity {
    color: #6b4423;
    font-weight: bold;
    margin-bottom: 8px;
}

.item-description {
    color: #5a3419;
    font-size: 0.9em;
    line-height: 1.4;
    font-style: italic;
}

/* タイトル画面専用スタイル */
.game-title {
    text-align: center;
    font-size: 2.2em;
    color: #4a2c17;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.title-nav {
    margin-top: 20px;
    text-align: center;
}

.nav-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
    justify-content: center;
}

.status-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 150px;
    padding: clamp(10px, 2.5vw, 18px);
    font-size: clamp(0.9em, 2vw, 1em);
    color: #f4e4bc;
    background: linear-gradient(145deg, #8b4513, #6b3410);
    border: 2px solid #5a2d0f;
    border-radius: 8px;
    font-family: 'Noto Serif JP', serif;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.3s ease, transform 0.2s ease;
.status-button:hover {
    background: linear-gradient(145deg, #a05016, #8b4513);
    transform: translateY(-1px);
}

.status-button:focus-visible {
    outline: 3px solid rgba(244, 228, 188, 0.6);
    outline-offset: 3px;
}
