/* 端末がダーク設定でも、明るい配色のまま見せる。 */
:root {
  color-scheme: only light;
  --bg: #fff8ec;
  --dot: #f3e6cf;
  --paper: #fffdf8;
  --ink: #3b2f2a;
  --ink-soft: #7a6a61;
  --edge: #e6d5b8;
  --leaf: #5bb98c;
  --leaf-2: #8fd4a8;
  --main: #ff8a65;
  --main-edge: #d9623f;
  --pin: #ffd166;
  --t-world: #e2f3ee;
  --t-personality: #ffe9e1;
  --t-role: #fff1c9;
  --t-motif: #e8e6fb;
  --t-palette: #fffdf8;
  --t-constraint: #e3f0fb;
}


* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px 16px 48px;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 2px, transparent 2px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  font-weight: 500;
  line-height: 1.7;
}

header, main, footer { max-width: 680px; margin-inline: auto; }

.site-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.logo { width: 48px; height: 48px; color: var(--ink); flex: none; }
.site-name { margin: 0; font-size: 1.6rem; font-weight: 900; line-height: 1.1; letter-spacing: 0.02em; }
.site-tagline { margin: 2px 0 0; font-size: 0.9rem; color: var(--ink-soft); }

.lang-link {
  margin-left: auto;
  padding: 4px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.lang-link:focus-visible { outline: 3px solid var(--leaf); outline-offset: 2px; }

.card {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 28px;
  padding: 22px 20px 20px;
  box-shadow: 0 8px 0 var(--edge);
}

.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; }
.next { margin: 0; font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); }
.card[data-kind="daily"] .pin { display: none; }

.kind {
  display: inline-block;
  margin: 0;
  padding: 2px 14px;
  border-radius: 999px;
  background: var(--leaf);
  color: #14382a;
  font-weight: 700;
  font-size: 0.85rem;
}

.sentence {
  margin: 12px 0 18px;
  font-size: clamp(1.25rem, 4.6vw, 1.7rem);
  font-weight: 900;
  line-height: 1.5;
  text-wrap: balance;
}

.tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.tile {
  position: relative;
  border: 2px solid var(--ink);
  border-radius: 18px;
  padding: 10px 12px 12px;
  box-shadow: 0 4px 0 var(--edge);
  min-height: 92px;
}
.tile[data-key="world"] { background: var(--t-world); }
.tile[data-key="personality"] { background: var(--t-personality); }
.tile[data-key="role"] { background: var(--t-role); }
.tile[data-key="motif"] { background: var(--t-motif); }
.tile[data-key="palette"] { background: var(--t-palette); grid-column: 1 / -1; }
.tile[data-key="constraint"] { background: var(--t-constraint); grid-column: 1 / -1; }
.tile.is-locked { box-shadow: 0 4px 0 var(--pin); }

.tile-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 8px; }
.tile-event {
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--leaf);
  color: #14382a;
  font-size: 0.7rem;
  white-space: nowrap;
}
.tile-event[hidden] { display: none; }
.tile-label {font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); }
.tile-value { margin: 4px 0 0; font-size: 1.2rem; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }

.tile-tools { display: flex; gap: 6px; }

.pin, .reroll {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  min-height: 28px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.pin[aria-pressed="true"] { background: var(--pin); color: #3b2f2a; }
.reroll { background: var(--main); color: #3b1a0e; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.swatch { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 700; }
.swatch i {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  display: block;
}

.actions, .share { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.share { justify-content: center; }

.btn {
  font: inherit;
  font-weight: 700;
  padding: 10px 18px;
  min-height: 46px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--edge);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--edge); }
.btn-main {
  flex: 1 1 200px;
  background: var(--main);
  color: #3b1a0e;
  font-size: 1.15rem;
  font-weight: 900;
  box-shadow: 0 5px 0 var(--main-edge);
}
.btn-x { background: var(--ink); color: var(--bg); }
.btn[hidden] { display: none; }

:is(.btn, .pin, .reroll):focus-visible { outline: 3px solid var(--leaf); outline-offset: 2px; }

.hint { margin: 12px 0 0; font-size: 0.8rem; color: var(--ink-soft); }

.about { margin-top: 36px; }
.about h2 { font-size: 1.1rem; font-weight: 900; margin: 0 0 6px; }
.about ol { margin: 0 0 10px; padding-left: 1.4em; }
.about p { margin: 0 0 8px; font-size: 0.9rem; color: var(--ink-soft); }
.about .note {
  margin: 14px 0 0;
  padding: 12px 16px;
  border: 2px dashed var(--ink-soft);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
}
.tag { font-weight: 700; background: var(--t-role); border-radius: 6px; padding: 1px 6px; }

.site-footer { margin-top: 36px; font-size: 0.8rem; color: var(--ink-soft); text-align: center; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

@keyframes pop {
  0% { transform: scale(0.9) rotate(-2deg); opacity: 0.2; }
  60% { transform: scale(1.04) rotate(1deg); opacity: 1; }
  100% { transform: none; }
}
.tile.pop { animation: pop 0.32s ease-out both; }

@media (prefers-reduced-motion: reduce) {
  .tile.pop { animation: none; }
  .btn, .toast { transition: none; }
}

/* スマホでは2列のまま詰めて、「お題をひく」までを1画面に収める */
@media (max-width: 420px) {
  body { padding-top: 16px; }
  .site-header { margin-bottom: 14px; }
  .card { padding: 16px 14px 16px; border-radius: 24px; }
  .sentence { margin: 8px 0 12px; }
  .tiles { gap: 10px; }
  .tile { padding: 8px 10px 10px; min-height: 0; }
  .tile-value { font-size: 1.05rem; }
  .swatches { gap: 8px; }
  .swatch { gap: 4px; font-size: 0.72rem; }
  .swatch i { width: 28px; height: 28px; }
  .actions { margin-top: 16px; }
}
