@font-face {
    font-family: 'saofont';
    src: url('../sao_font.ttf') format('truetype');
}

:root { --primary: #333; --bg: #f4f5f7; --box-bg: #fff; --accent: #e53e3e; --border: #ccc; --blue: #3182ce; --green: #38a169; }
html { height: 100%; background-color: var(--bg); }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; background-color: var(--bg); color: var(--primary); margin: 0; padding: env(safe-area-inset-top, 5px) env(safe-area-inset-right, 5px) env(safe-area-inset-bottom, 10px) env(safe-area-inset-left, 5px); min-height: 100vh; overflow-y: auto; -webkit-overflow-scrolling: touch; font-size: 14px; }
.container { max-width: 600px; margin: 0 auto; padding-bottom: 80px; }

.main-tabs { display: flex; overflow-x: auto; background: var(--box-bg); border-radius: 8px; margin-bottom: 15px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); scrollbar-width: none; -webkit-overflow-scrolling: touch; gap: 8px; padding: 0 8px; position: sticky; top: 0; z-index: 200; border-radius: 0; margin: 0; }
.main-tabs::-webkit-scrollbar { display: none; }
.m-tab-btn { flex: 0 0 auto; background: none; border: none; padding: 15px 20px; font-size: 0.95rem; font-weight: bold; color: #666; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; transition: color 0.2s; }
.m-tab-btn.active { color: var(--accent); border-bottom: 3px solid var(--accent); }

.tab-content { display: none; padding-top: 15px;}
.tab-content.active { display: block; }

.sub-tabs { display: flex; overflow-x: auto; margin-bottom: 15px; gap: 5px; scrollbar-width: none; position: sticky; top: 50px; z-index: 100; background-color: var(--bg); padding: 5px 0; transition: top 0.2s; }
.sub-tabs::-webkit-scrollbar { display: none; }
.s-tab-btn { background: #eee; border: none; padding: 8px 16px; border-radius: 20px; font-size: 0.85rem; color: #555; white-space: nowrap; cursor: pointer; font-weight: bold; transition: all 0.2s; }
.s-tab-btn.active { background: var(--primary); color: #fff; font-weight: bold; }
.s-tab-hist { background: #cbd5e0; color: #2d3748; font-weight: bold; position: sticky; right: 0; }
.s-tab-hist.active { background: var(--blue); color: #fff; }

.panel { background: var(--box-bg); padding: 15px; border-radius: 8px; margin-bottom: 15px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.panel-title { font-weight: bold; font-size: 1.05rem; margin-bottom: 12px; border-bottom: 2px solid #eee; padding-bottom: 5px; color: #444; display: flex; justify-content: flex-start; gap: 8px;  align-items: flex-end; }
.title-en { font-family: 'saofont', sans-serif; font-size: 1.6rem; font-weight: normal; color: var(--primary); line-height: 1; }
.title-jp { font-size: 0.85rem; font-weight: normal; color: #777; line-height: 1; margin-bottom: 3.15px; }
.ver-badge { font-family: 'saofont', sans-serif; }

.input-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.input-label { flex: 1; font-weight: bold; font-size: 0.95rem; }
.text-input { width: 80px; padding: 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 1rem; text-align: right; }
.text-input-wide { width: 170px; padding: 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 0.95rem; }

.counter-group { display: flex; align-items: center; gap: 6px; }
.btn-calc { width: 34px; height: 34px; font-size: 1.2rem; background: #fff; border: 1px solid #ccc; border-radius: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center; touch-action: manipulation; }
.btn-calc:active { background: #eee; }
.counter-val { font-size: 1.1rem; font-weight: bold; width: 40px; text-align: center; border: 1px solid #eee; padding: 4px; border-radius: 4px;}

.btn-hit { background: var(--accent); color: white; border: none; padding: 10px 12px; border-radius: 4px; font-weight: bold; cursor: pointer; font-size: 0.9rem; width:100%; box-sizing:border-box;}
.btn-hit:active { background: #c53030; }

.result-box { background: var(--box-bg); border-radius: 8px; padding: 20px 15px; text-align: center; border: 3px solid var(--primary); margin-bottom: 20px; }
.top-setting { font-size: 3.5rem; font-weight: bold; line-height: 1; margin: 5px 0; }
.top-percent { font-size: 1.2rem; font-weight: bold; color: #666; }
.setting-rainbow { color: transparent; background-clip: text; -webkit-background-clip: text; background-image: linear-gradient(to right, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #8b00ff, #ff0000); background-size: 200% auto; animation: textSlide 3s linear infinite; display: inline-block; }
.setting-gold { color: transparent; background-clip: text; -webkit-background-clip: text; background-image: linear-gradient(to right, #bf953f, #fcf6ba, #b38728, #fbf5b7, #aa771c, #bf953f); background-size: 200% auto; animation: textSlide 3s linear infinite; display: inline-block; }
@keyframes textSlide { to { background-position: -200% center; } }
.setting-red { color: var(--accent); }

.rank-list { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin-top: 15px; }
.rank-item { background: #eee; padding: 5px 10px; border-radius: 4px; font-size: 0.95rem; font-weight: bold; width: calc(33% - 10px); }

.factor-list { margin-top: 15px; }
.factor-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed #eee; font-size: 0.9rem; }

/* ▼▼▼ インフォボタン・モーダルスタイル ▼▼▼ */
.panel-title { display: flex; align-items: center; justify-content: space-between; }
.btn-info {
    background: #cbd5e0;
    color: #2d3748;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin-left: auto;
    flex-shrink: 0;
}
.btn-info:active { background: #a0aec0; }

body.no-scroll {
    overflow: hidden !important;
}

@keyframes bgFadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes popupAnim {
    0% { transform: translateY(20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 15px;
    animation: bgFadeIn 0.2s ease-out forwards;
}
.modal-content {
    background: #fff;
    border-radius: 8px;
    max-width: 480px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    box-sizing: border-box;
    animation: popupAnim 0.25s ease-out forwards;
}
.modal-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 8px;
    margin-bottom: 12px;
}
.modal-btn {
    width: 100%;
    padding: 10px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 10px;
}
.modal-btn:active { opacity: 0.9; }
textarea.memo-box { width: 100%; height: 150px; padding: 10px; border-radius: 6px; border: 1px solid var(--border); font-family: inherit; font-size: 0.95rem; resize: vertical; box-sizing: border-box; }

.info-table { width: 100%; border-collapse: collapse; margin-bottom: 15px; font-size: 0.85rem; text-align: center; }
.info-table th, .info-table td { border: 1px solid var(--border); padding: 5px 4px; }
.info-table th { background: #f0f4f8; font-weight: bold; color: #334155; }

.char-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 15px; }
.char-card { background: #fdfdfd; border: 1px solid var(--border); padding: 10px; border-radius: 8px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.char-name { font-weight: bold; margin-bottom: 8px; color: #333; }
.char-img { width: 48%; height: 75px; object-fit: cover; object-position: center; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }