:root {
    --primary: #ff5252;
    --bg: #f4f7f6;
    --card-bg: #ffffff;
    --text: #333;
    --border: #e0e0e0;
    --boost-plus: #ff5252;
    --boost-minus: #448aff;
    --mega-bg: #f3e5f5;
    --mega-text: #7b1fa2;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 10px;
    padding-bottom: 150px;
    touch-action: manipulation;
}
.container { max-width: 650px; margin: 0 auto; }

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

h2 { margin: 0 0 10px 0; font-size: 1.1rem; color: #444; border-bottom: 1px solid #eee; padding-bottom: 5px; }

.search-box { display: flex; gap: 8px; margin-bottom: 10px; position: relative; }
.search-box input { flex: 1; text-align: left; }

.suggestions {
    position: absolute; top: 100%; left: 0; right: 0;
    background: #fff; border: 1px solid #ddd; border-radius: 0 0 8px 8px;
    max-height: 200px; overflow-y: auto; z-index: 100;
    display: none; box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.suggestion-item { padding: 10px; border-bottom: 1px solid #eee; cursor: pointer; font-size: 0.9rem; }
.suggestion-item:hover { background: #f0f8ff; }

.poke-info {
    display: flex; align-items: center; gap: 10px;
    background: #fafafa; padding: 5px 10px; border-radius: 8px; margin-bottom: 10px;
    min-height: 50px;
}
.poke-img { width: 50px; height: 50px; object-fit: contain; background: #fff; border-radius: 50%; border: 1px solid #eee;}
.poke-details { display: flex; flex-direction: column; }
.poke-name { font-weight: bold; font-size: 0.9rem; }
.poke-types { font-size: 0.75rem; color: #666; margin-top: 2px;}
.type-badge {
    display: inline-block; padding: 2px 6px; border-radius: 4px; 
    font-size: 0.7rem; color: #fff; background: #999; margin-right: 4px;
}

.control-row {
    display: flex; align-items: flex-end; gap: 8px; margin-bottom: 8px; font-size: 0.8rem;
    flex-wrap: wrap;
}
.nature-select-wrap select,
.btn-mega,
.btn-stage,
.stage-value,
.speed-stage-control strong {
    height: 30px;
}
.nature-select-wrap, .speed-stage-control {
    display: flex; flex-direction: column; gap: 2px;
    font-weight: bold; color: #666;
}
.nature-select-wrap { width: 95px; }
.nature-select-wrap select {
    padding: 4px 6px; border: 1px solid var(--border);
    border-radius: 4px; background: #fff; color: var(--text); font-size: 0.8rem;
}
.nature-select-wrap select:focus { border-color: var(--primary); outline: none; }
.speed-stage-control {
    min-width: 92px;
}
.stage-buttons {
    display: grid; grid-template-columns: 28px 36px 28px 42px;
    align-items: center; gap: 2px;
}
.btn-stage {
    width: 28px; border: 1px solid #ddd; border-radius: 4px;
    background: #fff; color: #666; font-weight: bold; cursor: pointer;
}
.btn-stage:active { background: #f0f0f0; }
.stage-value {
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 4px; background: #fff; color: var(--text);
}
.speed-stage-control strong {
    min-width: 42px; padding: 0 6px; box-sizing: border-box;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 4px; background: #fff;
    font-size: 1rem; font-weight: 800;
}

.btn-mega {
    width: 70px;
    background-color: var(--mega-bg); color: var(--mega-text);
    border: 1px solid #d1c4e9; border-radius: 4px;
    font-weight: bold; font-size: 0.8rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.btn-mega.active { background-color: var(--mega-text); color: white; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.btn-mega:active { transform: scale(0.95); }

input {
    padding: 4px 2px;
    font-size: 0.9rem; border: 1px solid var(--border);
    border-radius: 4px; background: #fff; text-align: center; width: 100%; box-sizing: border-box;
}
input:focus { border-color: var(--primary); outline: none; }
 
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.grid-header, .stat-row {
    display: grid;
    grid-template-columns: 25px 44px minmax(148px, 1.1fr) 35px minmax(104px, 0.85fr);
    gap: 4px; align-items: center;
}

.grid-header { font-size: 0.65rem; color: #888; text-align: center; margin-bottom: 5px; }
.stat-row { margin-bottom: 6px; border-bottom: 1px solid #f9f9f9; padding-bottom: 6px; }
.stat-label { font-weight: bold; font-size: 0.8rem; text-align: center; }

.ev-area, .res-area { display: flex; align-items: center; gap: 2px; justify-content: center; }
.ev-area input { min-width: 42px; }
.btn-step, .btn-preset {
    height: 26px; padding: 0; box-sizing: border-box;
    border: 1px solid #ddd; border-radius: 3px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.btn-step {
    width: 20px; min-width: 20px;
    background: #fff; color: #666; font-size: 1.0rem; font-weight: bold;
}
.btn-preset {
    min-width: 22px; padding: 0 3px;
    background: #f0f0f0; color: #666; font-size: 0.8rem;
}
.btn-step:active, .btn-preset:active { background: #ddd; }

.nature-toggles { display: flex; gap: 2px; justify-content: center; flex-direction: column; }
.btn-nature {
    width: 100%; height: 16px; font-size: 1rem; font-weight: bold;
    border: 1px solid #eee; border-radius: 2px; background: #fff; color: #ccc;
    display: flex; align-items: center; justify-content: center; cursor: pointer; margin-bottom: 1px;
}
.btn-nature.active-plus { background: var(--boost-plus); color: white; border-color: var(--boost-plus); }
.btn-nature.active-minus { background: var(--boost-minus); color: white; border-color: var(--boost-minus); }

.result-val { 
    font-weight: bold; font-size: 1rem; color: var(--text); background: #fff;
}
.result-val:focus { background: #fafffa; border-color: var(--primary); }
.total-bar { text-align: right; font-size: 0.75rem; color: #666; margin-top: 5px; }
.text-alert { color: #ff5252; font-weight: bold; }

/* PC・タブレット向け横並び設定 */
@media screen and (min-width: 800px) {
    .container {
        max-width: 1200px;
        display: flex;
        gap: 20px;
        align-items: flex-start;
        padding: 20px;
    }
    #p1-wrapper, #p2-wrapper {
        flex: 1;
        width: 0;
        min-width: 400px;
    }
}
/* スマホ表示時のみフォントサイズを16px以上にする */
@media screen and (max-width: 768px) {
  input, textarea, select {
    font-size: 16px;
  }
  body {
    padding: 8px;
    padding-bottom: 120px;
  }
  .card {
    padding: 10px 8px;
  }
  .grid-header, .stat-row {
    grid-template-columns: 20px 38px minmax(118px, 1fr) 35px minmax(86px, 0.8fr);
    gap: 3px;
  }
  .grid-header {
    font-size: 0.58rem;
  }
  .stat-label {
    font-size: 0.74rem;
  }
  .ev-area, .res-area {
    gap: 1px;
  }
  .ev-area input {
    min-width: 34px;
    padding-left: 1px;
    padding-right: 1px;
  }
  .btn-step {
    width: 20px;
    min-width: 20px;
  }
  .btn-preset {
    min-width: 20px;
    padding: 0 2px;
    font-size: 0.8rem;
  }
  .result-val {
    width: 55px;
    font-size: 16px;
    padding-left: 1px;
    padding-right: 1px;
  }
}
