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

:root {
    --primary-color: #E07856;
    --primary-dark: #D46A47;
    --text-dark: #333;
    --text-light: #888;
    --border-color: #DCDCDC;
    --used-bg: #F5F5F5;
    --success-color: #4CAF50;
    --bg-color: #FFF8F5;
}

html, body {
    width: 100%;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
}

body {
    margin: 0;
    padding: 0;
}

/* スクリーン管理 */
.screen {
    display: none;
    width: 100%;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    overflow: hidden;
}

.main-screen-wrapper {
    position: static !important;
    height: auto !important;
    min-height: 100vh !important;
    overflow: visible !important;
    display: block !important;
}

.main-screen-content {
    padding: 20px;
    padding-bottom: 40px;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    z-index: 100;
}

.main-screen-wrapper.active {
    display: block !important;
    position: static !important;
    height: auto !important;
    overflow-y: auto !important;
    align-items: auto !important;
    justify-content: auto !important;
    z-index: 1 !important;
}

/* ヘッダー */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding-top: 20px;
}

.heart-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-light);
    font-weight: 400;
}

/* 統計情報 */
.stats {
    text-align: center;
    margin-bottom: 24px;
}

.stat-item {
    background: rgba(224, 120, 86, 0.1);
    border-radius: 20px;
    padding: 12px 20px;
    display: inline-block;
    margin: 0 auto;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    margin-right: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-dark);
    font-weight: 500;
}

/* チケット */
.tickets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 30px;
}

.ticket-card {
    background: white;
    border: 2px dashed var(--primary-color);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 140px;
    justify-content: center;
}

.ticket-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(224, 120, 86, 0.05) 10px,
        rgba(224, 120, 86, 0.05) 20px
    );
    pointer-events: none;
}

.ticket-card:hover:not(.used) {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(224, 120, 86, 0.15);
}

.ticket-card.used {
    background: var(--used-bg);
    border-color: var(--border-color);
    opacity: 0.6;
    cursor: not-allowed;
    position: relative;
}

.ticket-card.used::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: var(--success-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.ticket-icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 1;
}

.ticket-card.used .ticket-icon {
    opacity: 0.3;
}

.ticket-duration {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.ticket-card.used .ticket-duration {
    color: var(--text-light);
    text-decoration: line-through;
}

.ticket-label {
    font-size: 11px;
    color: var(--text-light);
}

.ticket-timestamp {
    font-size: 10px;
    color: #ccc;
    margin-top: 6px;
}

/* 履歴セクション */
.history-section {
    margin-top: 30px;
}

.history-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px 12px 16px;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 16px;
}

.history-icon {
    font-size: 18px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.history-item-ticket {
    font-weight: 600;
    color: var(--text-dark);
}

.history-item-time {
    font-size: 12px;
    color: var(--text-light);
}

.no-history {
    text-align: center;
    color: var(--text-light);
    padding: 20px;
    font-size: 13px;
}

/* モーダル */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 400px;
    width: 100%;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
}

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

.close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: var(--text-dark);
}

/* 確認画面 */
.confirm-label {
    text-align: center;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 12px;
}

.ticket-duration {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
    margin: 20px 0;
}

.confirm-note {
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 20px;
}

/* 準備画面 */
.prepare-modal {
    text-align: center;
}

.prepare-label {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.prepare-duration {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    margin: 16px 0 24px 0;
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    margin-bottom: 12px;
}

.prepare-note {
    font-size: 12px;
    color: var(--text-light);
}

/* ボタン */
.button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn {
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(224, 120, 86, 0.3);
}

.btn-secondary {
    background: white;
    color: var(--text-dark);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
}

/* タイマー画面 */
.timer-modal {
    text-align: center;
    padding: 40px 30px;
}

.timer-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.timer-subtitle {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 24px;
}

.timer-display {
    position: relative;
    width: 240px;
    height: 240px;
    margin: 0 auto 30px;
}

.progress-ring {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.progress-ring-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 10;
}

.progress-ring-fill {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.3s linear;
    stroke-dasharray: 691.15;
    stroke-dashoffset: 691.15;
}

.timer-time {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 56px;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
}

/* バックグラウンドウィジェット */
.timer-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 80px;
    height: 80px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    font-family: 'Courier New', monospace;
    z-index: 999;
}

.timer-widget.hidden {
    display: none;
}

/* リスポンシブ */
@media (max-width: 600px) {
    .header h1 {
        font-size: 28px;
    }

    .tickets-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .modal {
        padding: 24px 20px;
        max-width: 90%;
    }

    .timer-display {
        width: 200px;
        height: 200px;
    }

    .timer-time {
        font-size: 48px;
    }
}
