/* Make15 — 和モダン × ミニマル */

:root {
  --bg: #FAF7F2;
  --ink: #1A1A1A;
  --accent: #D2454D;
  --moss: #5C7A4A;
  --card-bg: #FFFFFF;
  --card-border: #D4D0C8;
  --muted: #8A857C;
  --soft: #EFEBE3;
  --shadow: 0 2px 6px rgba(26, 26, 26, 0.08);
  --shadow-lift: 0 6px 16px rgba(26, 26, 26, 0.16);
  --radius: 10px;
  --radius-card: 14px;
  --serif: 'Noto Serif JP', 'Hiragino Mincho ProN', 'Yu Mincho', serif;
  --sans: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
body {
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
}
button:disabled { cursor: not-allowed; opacity: 0.4; }

/* ----- Header ----- */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
}
.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.logo {
  font-family: var(--serif);
  font-size: 22px;
  margin: 0;
  letter-spacing: 0.02em;
  line-height: 1.2;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.logo a { color: var(--ink); }
.logo a:hover { text-decoration: none; }
.logo-main { white-space: nowrap; }
.logo-num { color: var(--accent); margin-left: 2px; }
.logo-sub {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 480px) {
  .logo-sub { font-size: 9.5px; }
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.best-score {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.best-score strong {
  color: var(--ink);
  font-weight: 700;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.15s ease, transform 0.1s ease;
}
.icon-btn:hover:not(:disabled) { background: #e6e1d6; }
.icon-btn:active:not(:disabled) { transform: scale(0.94); }

/* ----- Main game ----- */
.game {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px;
}

.status {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--soft);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--muted);
}
.status-item strong {
  color: var(--ink);
  font-weight: 700;
  margin: 0 2px;
  font-variant-numeric: tabular-nums;
}

.pass-hint {
  text-align: center;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-weight: 700;
  margin: 0 0 12px;
  animation: pulse 1.4s ease-in-out infinite;
}

/* ----- 計算結果（場のスロット内に表示） ----- */
.running-card {
  background: #FFF5F4;
  border: 2px solid var(--accent);
  cursor: pointer;
  touch-action: none;
}
.running-card .card-num { color: var(--accent); }
.running-card.is-target {
  animation: target-pulse 1.4s ease-in-out infinite;
}
.running-card.is-drop-target {
  background: #F2F6EC;
  border-color: var(--moss);
  box-shadow: 0 0 0 4px rgba(92,122,74,0.22);
}
@keyframes target-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(210,69,77,0.0); }
  50% { box-shadow: 0 0 0 6px rgba(210,69,77,0.20); }
}
.running-weight {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.running-card.is-target .running-weight { color: var(--accent); }
.running-grab {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 10px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 8px rgba(210,69,77,0.3);
}
.running-reset {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--muted);
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  font-weight: 400;
  cursor: pointer;
  z-index: 2;
  pointer-events: auto;
}
.running-reset:hover { background: #e6e1d6; color: var(--ink); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ----- Field (cards) — 上段2 / 下段3 ----- */
.field {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-rows: auto;
  gap: 8px;
  margin: 0 auto 14px;
  min-height: 110px;
  max-width: 300px;
}
.field > *:nth-child(1) { grid-column: 2 / span 2; grid-row: 1; }
.field > *:nth-child(2) { grid-column: 4 / span 2; grid-row: 1; }
.field > *:nth-child(3) { grid-column: 1 / span 2; grid-row: 2; }
.field > *:nth-child(4) { grid-column: 3 / span 2; grid-row: 2; }
.field > *:nth-child(5) { grid-column: 5 / span 2; grid-row: 2; }
.field-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 30px 0;
  font-size: 14px;
}

.card-empty {
  aspect-ratio: 5 / 7;
  border: 1.5px dashed var(--card-border);
  border-radius: var(--radius-card);
  background: transparent;
  opacity: 0.4;
  pointer-events: none;
}

.card {
  position: relative;
  aspect-ratio: 5 / 7;
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  font-family: var(--sans);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  touch-action: none;
}
.card * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}
.card:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}
.card:active:not(:disabled) {
  transform: translateY(0);
}
.card.is-target {
  border-color: var(--accent);
  background: #FFF5F4;
  animation: target-pulse 1.4s ease-in-out infinite;
}
.card.is-target .card-num { color: var(--accent); }
.card-grab {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.card-num {
  font-size: clamp(20px, 6.5vw, 32px);
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.card-mark {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 30%, transparent 32%);
  opacity: 0.55;
}

/* パスモード時はカードを赤い枠で強調 */
body.pass-mode .card {
  border-color: var(--accent);
  animation: pass-glow 1.2s ease-in-out infinite;
}
@keyframes pass-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(210, 69, 77, 0.0); }
  50% { box-shadow: 0 0 0 4px rgba(210, 69, 77, 0.18); }
}

/* ドラッグ中の演出 */
body.is-dragging { user-select: none; cursor: grabbing; }
.card { cursor: pointer; }
@media (hover: hover) {
  .card:hover:not(:disabled) { cursor: grab; }
}
.card.is-grabbed {
  box-shadow: 0 14px 28px rgba(26,26,26,0.28);
  z-index: 200;
  opacity: 0.96;
  pointer-events: none;
  cursor: grabbing;
}
.card.is-drop-target {
  border-color: var(--moss);
  box-shadow: 0 0 0 4px rgba(92, 122, 74, 0.22), var(--shadow);
  transform: translateY(-3px);
}

/* 演算子ピッカー */
.op-picker {
  position: fixed;
  inset: 0;
  background: rgba(26,26,26,0.35);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.op-picker.is-open { opacity: 1; }
.op-picker-card {
  position: absolute;
  width: 220px;
  background: var(--bg);
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(26,26,26,0.32);
  padding: 14px;
}
.op-picker-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
  font-family: var(--sans);
}
.op-picker-num {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  min-width: 1.5em;
  text-align: center;
}
.op-picker-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
  background: #FFF5F4;
}
.op-picker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.op-picker-btn {
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 0;
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, background 0.12s ease, border-color 0.12s ease;
}
.op-picker-btn:hover:not(:disabled) { background: var(--soft); border-color: var(--moss); }
.op-picker-btn:active:not(:disabled) { transform: scale(0.94); }
.op-picker-sym { font-size: 22px; font-weight: 700; color: var(--ink); }
.op-picker-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.op-picker-btn:disabled .op-picker-val { color: var(--card-border); }
.op-picker-btn.is-target {
  border-color: var(--accent);
  background: #FFF5F4;
}
.op-picker-btn.is-target .op-picker-val { color: var(--accent); }
.op-picker-btn.is-target .op-picker-sym { color: var(--accent); }
.op-picker-cancel {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px 0;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
}
.op-picker-cancel:hover { background: var(--soft); color: var(--ink); }

.swipe-hint {
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  margin: 8px 0 12px;
  line-height: 1.5;
  letter-spacing: 0.02em;
}

.field.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.feedback {
  min-height: 26px;
  text-align: center;
  margin-top: 8px;
  font-weight: 700;
  font-size: 16px;
  color: transparent;
  transition: color 0.2s ease;
}
.feedback.is-success {
  color: var(--accent);
  font-size: 22px;
  animation: pop 0.4s ease;
}
.feedback.is-fail { color: var(--muted); }
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ----- Utility row (parens, backspace, clear) ----- */
.ops {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.op-btn {
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius);
  padding: 10px 0;
  font-size: 14px;
  font-weight: 400;
  font-family: var(--sans);
  color: var(--muted);
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.op-btn:hover:not(:disabled) { background: var(--soft); }
.op-btn:active:not(:disabled) {
  transform: scale(0.96);
  border-color: var(--moss);
}

/* ----- Action buttons ----- */
.actions {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.btn {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  font-family: var(--sans);
  border: 1.5px solid transparent;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #b93b42; }
.btn-secondary {
  background: var(--card-bg);
  color: var(--ink);
  border-color: var(--card-border);
}
.btn-secondary:hover:not(:disabled) { background: var(--soft); }

/* ----- End banner ----- */
.end-banner {
  background: var(--card-bg);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin-top: 14px;
  box-shadow: var(--shadow-lift);
}
.end-banner h2 {
  font-family: var(--serif);
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 28px;
}
.end-banner p { margin: 6px 0; color: var(--ink); }
.end-banner strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.end-banner .btn { margin-top: 12px; min-width: 140px; }

/* ----- Ad slots ----- */
.ad-slot {
  margin: 20px 0;
  min-height: 90px;
  background: transparent;
}
.ad-slot:empty::before {
  content: '';
  display: block;
  height: 0;
}
.affiliate-block { margin-top: 16px; }

/* ----- LP / SEO body copy ----- */
.lp {
  max-width: 720px;
  margin: 24px auto 0;
  padding: 24px 18px;
  background: #fff;
  border-top: 1px solid var(--card-border);
}
.lp h2 {
  font-family: var(--serif);
  font-size: 22px;
  margin-top: 0;
}
.lp h3 {
  font-family: var(--serif);
  font-size: 17px;
  margin-top: 24px;
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}
.lp ol, .lp ul { padding-left: 1.4em; }
.lp li { margin: 4px 0; }
.lp code {
  background: var(--soft);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.95em;
}
.lp-related { margin-top: 24px; font-size: 14px; color: var(--muted); }

/* ----- Footer ----- */
.site-footer {
  text-align: center;
  padding: 30px 14px;
  font-size: 12px;
  color: var(--muted);
}

/* ----- Modal ----- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal[hidden] { display: none; }
.modal-inner {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 28px 22px;
  max-width: 460px;
  width: 100%;
  position: relative;
  box-shadow: var(--shadow-lift);
  max-height: 86vh;
  overflow-y: auto;
}
.modal-inner h2 {
  font-family: var(--serif);
  margin: 0 0 14px;
}
.modal-inner ul { padding-left: 1.4em; }
.modal-inner li { margin: 6px 0; }
.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 20px;
  background: transparent;
  color: var(--muted);
}
.modal-close:hover { background: var(--soft); color: var(--ink); }
.modal-inner .btn.modal-close {
  position: static;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin-top: 16px;
  font-size: 16px;
  color: #fff;
}

/* ----- FX Layer (success burst, op flash) ----- */
.fx-layer {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 50;
}
.op-flash {
  position: absolute;
  top: -120px;
  left: 0;
  transform: translate(-50%, 0);
  font-family: var(--sans);
  font-size: 64px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 4px 16px rgba(210, 69, 77, 0.35);
  animation: op-flash 0.55s ease-out forwards;
}
@keyframes op-flash {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(0.6); }
  30% { opacity: 1; transform: translate(-50%, 0) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -16px) scale(1); }
}
.fx-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  top: 0;
  left: 0;
  --dx: 0px;
  --dy: 0px;
  animation: fx-burst 0.85s ease-out forwards;
}
@keyframes fx-burst {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.4); opacity: 0; }
}

/* ----- Narrow phones ----- */
@media (max-width: 380px) {
  .game { padding: 10px; }
  .field { gap: 6px; max-width: 260px; }
  .ops { gap: 6px; }
  .op-btn { padding: 8px 0; }
  .card-num { font-size: 24px; }
  .btn { padding: 12px 14px; }
}

/* ----- Wider screens ----- */
@media (min-width: 720px) {
  .field { gap: 10px; max-width: 320px; }
  .card-num { font-size: 28px; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
