:root {
    --bg-color: #f4f7f9;
}

* { box-sizing: border-box; }

body, html {
    margin: 0; padding: 0; width: 100%;
    font-family: 'Quicksand', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    background-color: var(--bg-color);
    user-select: none; -webkit-touch-callout: none;
    overflow-x: hidden;
}

#app-container {
    display: flex; flex-direction: column; 
    height: 100vh; position: relative; overflow: hidden;
}

.is-fullscreen #header,
.is-fullscreen #page-bottom {
    display: none !important;
}

#header {
    background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(8px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04); padding: 12px 20px;
    display: flex; justify-content: space-between; align-items: center;
    z-index: 10; position: relative;
}
.header-left { display: flex; align-items: center; gap: 15px; }

.icon-btn {
    background: transparent; border: 2px solid #ddd; border-radius: 8px;
    font-size: 1.5rem; color: #555; padding: 4px 12px; cursor: pointer; transition: 0.2s;
}
.icon-btn:hover { background: #f0f0f0; border-color: #ccc; }

.layout-toggle { display: flex; gap: 5px; background: #eee; padding: 4px; border-radius: 20px; }
.layout-toggle button {
    border: none; background: transparent; border-radius: 16px; padding: 6px 16px;
    font-size: 1.2rem; cursor: pointer; color: #888; transition: 0.3s;
}
.layout-toggle button.active { background: #fff; color: #0a3090; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }

.control-group { display: flex; align-items: center; gap: 8px; }
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc; transition: .4s; border-radius: 24px;
}
.slider:before {
    position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
    background-color: white; transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: #2a75ff; }
input:checked + .slider:before { transform: translateX(20px); }
.mode-label { font-size: 0.9rem !important; color: #555; font-weight: bold; cursor: pointer; }

#grid-container { flex: 1; width: 100%; height: 100%; position: relative; background: #ffffff; }

#grid-container.layout-grid { display: flex; flex-wrap: wrap; padding: 6px; gap: 6px; }
.layout-grid .color-zone { flex-grow: 1; position: relative; border-radius: 16px; box-shadow: inset 0 0 20px rgba(255,255,255,0.3); overflow: hidden; }

#grid-container.layout-circle { display: block; overflow: hidden; }
.layout-circle .color-zone { position: absolute; width: 100%; height: 100%; top: 0; left: 0; transform-origin: 50% 50%; }

.color-zone { transition: background-color 0.4s; }

.content-wrapper {
    position: absolute; top: 50%; left: 50%; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center; pointer-events: none;
}

.tap-text {
    font-size: clamp(3rem, 8vw, 6rem); font-weight: 900; letter-spacing: 2px;
    color: rgba(255,255,255,0.95); text-shadow: 0 4px 10px rgba(0,0,0,0.25);
    position: absolute; opacity: 0; transition: opacity 0.3s;
}
.color-zone.waiting .tap-text.tap-wait { opacity: 1; animation: pulse 1.5s infinite; }
.color-zone.claimed .tap-text.tap-ok { opacity: 1; animation: fadeOutText 1.2s forwards; }

.number-display {
    font-size: clamp(6rem, 25vw, 15rem); font-weight: 900; color: #ffffff;
    text-shadow: 2px 4px 12px rgba(0,0,0,0.15); opacity: 0;
    transform: perspective(500px) rotateY(90deg) scale(0.5); position: absolute;
}
.show-number { animation: flipIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.color-zone::after {
    content: ''; position: absolute; top:0; left:0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.4); opacity: 0; transform: scale(0); border-radius: 50%; pointer-events: none;
}
.color-zone.animate-ripple::after { animation: ripple 0.6s ease-out; }

@keyframes pulse { 0% { transform: scale(0.95); } 50% { transform: scale(1.05); } 100% { transform: scale(0.95); } }
@keyframes fadeOutText { 0% { transform: scale(0.5); } 15% { transform: scale(1.2); } 30% { transform: scale(1); } 100% { opacity: 0; } }
@keyframes ripple { 0% { transform: scale(0); opacity: 1; } 100% { transform: scale(2.5); opacity: 0; } }
@keyframes flipIn {
    0% { transform: perspective(500px) rotateY(90deg) scale(0.5); opacity: 0; }
    50% { transform: perspective(500px) rotateY(-15deg) scale(1.1); opacity: 1; }
    100% { transform: perspective(500px) rotateY(0deg) scale(1); opacity: 1; }
}

#dial-container {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 360px; height: 360px; z-index: 100;
    border-radius: 50%; touch-action: none; cursor: grab;
}
#dial-container:active { cursor: grabbing; }

#dial-ticks {
    position: absolute; width: 100%; height: 100%; top: 0; left: 0;
    pointer-events: none; transition: opacity 0.3s;
}
.tick {
    position: absolute; top: 15px; left: calc(50% - 1.5px); 
    width: 3px; height: 14px; background: #c5cbd3;
    transform-origin: 50% 165px; 
    border-radius: 2px; transition: background 0.1s, box-shadow 0.1s;
}
.tick.active { background: #2a75ff; box-shadow: 0 0 8px #2a75ff; }

#center-btn {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 240px; height: 240px; border-radius: 50%; 
    background: transparent; border: none; padding: 0;
    cursor: pointer; display: flex; justify-content: center; align-items: center;
}

#knob-visual {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #ffffff 0%, #edf1f4 60%, #dfe4ea 100%);
    border: 8px solid #0a3090;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05), 0 15px 25px rgba(0,0,0,0.15), 0 0 0 1px #041c5a;
}
#center-btn:active:not(:disabled) #knob-visual {
    box-shadow: inset 0 0 20px rgba(0,0,0,0.1), 0 5px 10px rgba(0,0,0,0.15), 0 0 0 1px #041c5a;
}
#center-btn:disabled #knob-visual {
    background: radial-gradient(circle at 30% 30%, #f7f9fa 0%, #e6ebf0 100%);
    border-color: #a0aab5; box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

#knob-content {
    position: relative; z-index: 10; pointer-events: none;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
}
.btn-text {
    display: flex; align-items: baseline; justify-content: center;
    color: #2c3e50; text-shadow: 0 2px 4px rgba(255,255,255,0.9);
}
.val-num { font-size: 5rem; font-weight: 900; line-height: 1; }
.val-unit { font-size: 1.6rem; font-weight: bold; margin-left: 5px; }
.btn-subtext { font-size: 1.1rem; font-weight: bold; margin-top: 5px; color: #6a7c92; }

.state-ready #dial-ticks { opacity: 0; }
.state-done #dial-ticks { opacity: 0; }


/* === 使い方・シェア・フッター領域 === */
#page-bottom {
    background-color: var(--bg-color);
    padding: 60px 20px 40px;
}

/* 使い方枠 */
#usage-section {
    max-width: 800px; margin: 0 auto 50px;
    background: #fdfdfc; border: 1px solid #eaddc4; border-radius: 8px;
    padding: 30px; box-shadow: 0 4px 15px rgba(0,0,0,0.02);
}
#usage-section h3 {
    font-size: 1.2rem; color: #4a4a4a;
    margin-top: 0; margin-bottom: 20px;
    display: flex; align-items: center; gap: 8px;
}
#usage-section ul {
    list-style-type: disc; padding-left: 24px; margin: 0;
    color: #555; font-size: 0.95rem; line-height: 1.8;
}
#usage-section li { margin-bottom: 12px; }
#usage-section li:last-child { margin-bottom: 0; }

/* シェア枠 */
#share-section {
    text-align: center; margin-bottom: 60px;
}
.share-title {
    font-size: 1rem; color: #666; margin-bottom: 15px; font-weight: bold;
}
.share-buttons {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 15px;
}
.share-icon-btn {
    display: flex; align-items: center; justify-content: center;
    width: 50px; height: 50px; border-radius: 50%; font-weight: bold; font-size: 1.5rem;
    text-decoration: none; color: white; transition: 0.2s; cursor: pointer; border: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.share-icon-btn:hover { opacity: 0.85; transform: translateY(-3px); box-shadow: 0 6px 15px rgba(0,0,0,0.15); }
.btn-x { background-color: #000000; }
.btn-fb { background-color: #1877F2; }
.btn-line { background-color: #06C755; }
.btn-line img { width: 28px; }
.btn-copy { background-color: #ffffff; color: #333; font-size: 1.3rem; }

/* フッター */
#footer {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
    max-width: 1000px; margin: 0 auto; padding-top: 20px;
    border-top: 1px solid #e1e4e8; color: #55606e; font-size: 0.9rem;
}
.footer-left { display: flex; gap: 20px; }
.footer-left a { color: #55606e; text-decoration: none; font-weight: bold; transition: color 0.2s; }
.footer-left a:hover { color: #2a75ff; }
.footer-right { font-weight: bold; }

@media (max-width: 600px) {
    #header { flex-direction: column; gap: 10px; }
    #usage-section { padding: 20px; }
    #footer { flex-direction: column; gap: 15px; text-align: center; }
}