/* =========================================================
   基本設定
========================================================= */

:root {
  --paper: #fffdf7;
  --paper-deep: #f7f0df;
  --cream: #f3e7cd;

  --wood-light: #d7b27a;
  --wood: #ad7b45;
  --wood-dark: #79502d;

  --brown: #5b402d;
  --brown-soft: #80624c;

  --green: #728665;
  --green-dark: #53654a;

  --pink: #c98e91;
  --pink-dark: #a96f73;

  --gold: #b98b43;

  --shadow-soft:
    0 8px 20px rgba(83, 58, 37, 0.14);

  --shadow-card:
    0 12px 28px rgba(83, 58, 37, 0.18);

  --radius-small: 10px;
  --radius-medium: 16px;
  --radius-large: 24px;
}


*,
*::before,
*::after {
  box-sizing: border-box;
}


html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}


body {
  min-height: 100vh;
  margin: 0;

  color: var(--brown);

  font-family:
    "Hiragino Maru Gothic ProN",
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    "Meiryo",
    sans-serif;

  background:
    radial-gradient(
      circle at top left,
      rgba(255, 255, 255, 0.75),
      transparent 34%
    ),
    linear-gradient(
      145deg,
      #f2e5cf 0%,
      #e8d6bb 48%,
      #d9bea0 100%
    );

  background-attachment: fixed;

  -webkit-tap-highlight-color: transparent;
}


button,
input,
summary {
  font: inherit;
}


button {
  color: inherit;
}


img {
  display: block;
  max-width: 100%;
}


[hidden] {
  display: none !important;
}


/* =========================================================
   アクセシビリティ
========================================================= */

.visually-hidden {
  position: absolute !important;

  width: 1px !important;
  height: 1px !important;

  padding: 0 !important;
  margin: -1px !important;

  overflow: hidden !important;

  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;

  border: 0 !important;
}


button:focus-visible,
summary:focus-visible,
input:focus-visible + span {
  outline: 3px solid rgba(114, 134, 101, 0.55);
  outline-offset: 4px;
}


/* =========================================================
   全体レイアウト
========================================================= */

.game-container {
  position: relative;

  width: min(100%, 720px);

  margin: 0 auto;
  padding:
    max(24px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(34px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}


.screen {
  width: 100%;
}


.start-screen,
.game-screen {
  animation: screenFade 0.35s ease;
}


@keyframes screenFade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* =========================================================
   音ボタン
========================================================= */

.sound-toggle-button {
  position: absolute;

  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));

  z-index: 10;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  gap: 7px;

  min-height: 42px;

  padding: 8px 13px;

  color: var(--brown);

  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.88),
      rgba(247, 240, 223, 0.94)
    );

  border: 1px solid rgba(121, 80, 45, 0.22);
  border-radius: 999px;

  box-shadow:
    0 5px 14px rgba(83, 58, 37, 0.13);

  cursor: pointer;

  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease;
}


.sound-toggle-button:active {
  transform: translateY(1px) scale(0.98);
  box-shadow:
    0 2px 8px rgba(83, 58, 37, 0.12);
}


.sound-toggle-icon {
  display: grid;
  place-items: center;

  width: 24px;
  height: 24px;

  color: #fff;

  font-size: 15px;
  font-weight: 700;

  line-height: 1;

  background: var(--green);
  border-radius: 50%;
}


.sound-toggle-button[aria-pressed="true"]
.sound-toggle-icon {
  background: var(--brown-soft);
}


.sound-toggle-text {
  font-size: 13px;
  font-weight: 700;
}


/* =========================================================
   ヘッダー
========================================================= */

.game-header {
  padding: 52px 12px 22px;

  text-align: center;
}


.game-label {
  display: inline-block;

  margin: 0 0 9px;
  padding: 5px 14px;

  color: #fff;

  font-size: 13px;
  font-weight: 700;

  letter-spacing: 0.12em;

  background: var(--green);
  border-radius: 999px;

  box-shadow:
    0 4px 10px rgba(83, 101, 74, 0.18);
}


.game-header h1 {
  margin: 0;

  color: var(--brown);

  font-size: clamp(28px, 6vw, 43px);
  font-weight: 800;

  line-height: 1.28;
  letter-spacing: 0.04em;

  text-shadow:
    0 2px 0 rgba(255, 255, 255, 0.6);
}


.game-description {
  margin: 14px 0 0;

  color: var(--brown-soft);

  font-size: clamp(14px, 3.5vw, 17px);
  line-height: 1.8;
}


.mobile-break {
  display: none;
}


/* =========================================================
   スタート画面
========================================================= */

.start-screen {
  display: flex;
  flex-direction: column;

  gap: 22px;
}


/* =========================================================
   思い出カード
========================================================= */

.memory-card {
  position: relative;

  width: 100%;

  padding: 24px;

  text-align: center;

  background:
    linear-gradient(
      160deg,
      rgba(255, 255, 255, 0.95),
      rgba(255, 250, 238, 0.96)
    );

  border:
    1px solid rgba(121, 80, 45, 0.18);

  border-radius: var(--radius-large);

  box-shadow: var(--shadow-card);
}


.memory-card::before,
.memory-card::after {
  content: "";

  position: absolute;
  pointer-events: none;
}


.memory-card::before {
  inset: 8px;

  border:
    1px dashed rgba(173, 123, 69, 0.22);

  border-radius:
    calc(var(--radius-large) - 7px);
}


.memory-card::after {
  top: 16px;
  left: 50%;

  width: 72px;
  height: 15px;

  transform: translateX(-50%) rotate(-1deg);

  background:
    rgba(218, 191, 143, 0.45);

  border-radius: 2px;
}


.memory-card-label {
  position: relative;
  z-index: 1;

  margin: 10px 0 14px;

  color: var(--gold);

  font-size: 13px;
  font-weight: 800;

  letter-spacing: 0.14em;
}


.memory-preview-wrap {
  position: relative;
  z-index: 1;

  width: min(100%, 440px);
  aspect-ratio: 1 / 1;

  margin: 0 auto;

  padding: 10px;

  background:
    linear-gradient(
      145deg,
      var(--wood-light),
      var(--wood),
      var(--wood-dark)
    );

  border-radius: 18px;

  box-shadow:
    0 9px 20px rgba(83, 58, 37, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}


.memory-preview-wrap::after {
  content: "";

  position: absolute;
  inset: 6px;

  border:
    1px solid rgba(255, 255, 255, 0.24);

  border-radius: 13px;

  pointer-events: none;
}


.memory-preview {
  width: 100%;
  height: 100%;

  object-fit: cover;

  background: var(--paper-deep);

  border-radius: 10px;
}


.memory-title {
  position: relative;
  z-index: 1;

  margin: 20px 0 13px;

  color: var(--brown);

  font-size: clamp(21px, 5vw, 29px);
  line-height: 1.45;
}


.change-memory-button {
  position: relative;
  z-index: 1;

  min-height: 42px;

  padding: 9px 17px;

  color: var(--green-dark);

  font-size: 14px;
  font-weight: 700;

  background:
    rgba(255, 255, 255, 0.72);

  border:
    1px solid rgba(83, 101, 74, 0.34);

  border-radius: 999px;

  cursor: pointer;

  transition:
    transform 0.15s ease,
    background-color 0.15s ease;
}


.change-memory-button:active {
  transform: scale(0.98);

  background:
    rgba(238, 244, 233, 0.92);
}


/* =========================================================
   難易度選択
========================================================= */

.difficulty-area {
  margin: 0;
  padding: 20px;

  background:
    rgba(255, 253, 247, 0.86);

  border:
    1px solid rgba(121, 80, 45, 0.18);

  border-radius: var(--radius-medium);

  box-shadow: var(--shadow-soft);
}


.difficulty-area legend {
  padding: 0 11px;

  color: var(--brown);

  font-size: 16px;
  font-weight: 800;

  text-align: center;
}


.difficulty-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);

  gap: 10px;
}


.difficulty-option {
  display: block;

  cursor: pointer;
}


.difficulty-option input {
  position: absolute;

  width: 1px;
  height: 1px;

  opacity: 0;
  pointer-events: none;
}


.difficulty-option span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  min-height: 76px;

  padding: 10px 7px;

  color: var(--brown-soft);

  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.9),
      rgba(247, 240, 223, 0.9)
    );

  border:
    2px solid rgba(173, 123, 69, 0.2);

  border-radius: 14px;

  box-shadow:
    0 4px 10px rgba(83, 58, 37, 0.08);

  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background-color 0.15s ease,
    box-shadow 0.15s ease;
}


.difficulty-option strong {
  font-size: 20px;
  line-height: 1.2;
}


.difficulty-option small {
  margin-top: 5px;

  font-size: 12px;
  font-weight: 700;
}


.difficulty-option input:checked + span {
  color: var(--green-dark);

  background:
    linear-gradient(
      180deg,
      #f4f8ef,
      #e7efdf
    );

  border-color: var(--green);

  box-shadow:
    0 5px 14px rgba(83, 101, 74, 0.17),
    inset 0 0 0 1px rgba(255, 255, 255, 0.7);

  transform: translateY(-2px);
}


/* =========================================================
   共通ボタン
========================================================= */

.main-button,
.sub-button,
.text-button {
  width: 100%;

  border: 0;

  cursor: pointer;

  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    filter 0.15s ease;
}


.main-button {
  min-height: 58px;

  padding: 14px 22px;

  color: #fff;

  font-size: 17px;
  font-weight: 800;

  letter-spacing: 0.05em;

  background:
    linear-gradient(
      180deg,
      #809475,
      var(--green)
    );

  border:
    1px solid var(--green-dark);

  border-radius: 16px;

  box-shadow:
    0 7px 0 var(--green-dark),
    0 12px 20px rgba(83, 101, 74, 0.19);
}


.main-button:active {
  transform: translateY(5px);

  box-shadow:
    0 2px 0 var(--green-dark),
    0 6px 12px rgba(83, 101, 74, 0.14);
}


.sub-button {
  min-height: 50px;

  padding: 12px 18px;

  color: var(--brown);

  font-size: 15px;
  font-weight: 800;

  background:
    linear-gradient(
      180deg,
      #fffef9,
      #f2e6cf
    );

  border:
    1px solid rgba(121, 80, 45, 0.26);

  border-radius: 14px;

  box-shadow:
    0 5px 0 rgba(121, 80, 45, 0.2),
    0 8px 14px rgba(83, 58, 37, 0.1);
}


.sub-button:active {
  transform: translateY(3px);

  box-shadow:
    0 2px 0 rgba(121, 80, 45, 0.2),
    0 4px 8px rgba(83, 58, 37, 0.08);
}


.text-button {
  min-height: 42px;

  padding: 8px;

  color: var(--brown-soft);

  font-size: 14px;
  font-weight: 700;

  background: transparent;

  text-decoration: underline;
  text-decoration-color:
    rgba(128, 98, 76, 0.42);

  text-underline-offset: 4px;
}


.text-button:active {
  transform: scale(0.98);
}


/* =========================================================
   ゲーム画面
========================================================= */

.game-screen {
  padding-top: 8px;
}


/* =========================================================
   時間・手数
========================================================= */

.status-panel {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;

  width: min(100%, 470px);

  margin: 0 auto 18px;
  padding: 13px 18px;

  background:
    rgba(255, 253, 247, 0.92);

  border:
    1px solid rgba(121, 80, 45, 0.2);

  border-radius: 999px;

  box-shadow: var(--shadow-soft);
}


.status-item {
  display: flex;
  flex-direction: column;
  align-items: center;

  gap: 2px;
}


.status-label {
  color: var(--brown-soft);

  font-size: 12px;
  font-weight: 700;
}


.status-item strong {
  color: var(--brown);

  font-size: 22px;
  line-height: 1.2;

  font-variant-numeric: tabular-nums;
}


.status-divider {
  width: 1px;
  height: 35px;

  margin: 0 18px;

  background:
    rgba(121, 80, 45, 0.2);
}


/* ===== ここまでCSS前半 ===== */

/* =========================================================
   パズルエリア
========================================================= */

.puzzle-area {
  width: 100%;
}


.puzzle-frame {
  position: relative;

  width: min(100%, 520px);

  margin: 0 auto;
  padding: 14px;

  background:
    linear-gradient(
      145deg,
      var(--wood-light) 0%,
      var(--wood) 52%,
      var(--wood-dark) 100%
    );

  border:
    1px solid rgba(91, 64, 45, 0.42);

  border-radius: 22px;

  box-shadow:
    0 14px 27px rgba(83, 58, 37, 0.24),
    inset 0 2px 0 rgba(255, 255, 255, 0.28),
    inset 0 -3px 0 rgba(91, 64, 45, 0.18);
}


.puzzle-frame::before {
  content: "";

  position: absolute;
  inset: 6px;

  border:
    1px solid rgba(255, 255, 255, 0.22);

  border-radius: 17px;

  pointer-events: none;
}


.puzzle-frame::after {
  content: "";

  position: absolute;
  inset: 10px;

  border:
    1px solid rgba(91, 64, 45, 0.16);

  border-radius: 14px;

  pointer-events: none;
}


/* =========================================================
   パズル盤面
========================================================= */

.puzzle-board {
  position: relative;
  z-index: 1;

  display: grid;

  width: 100%;
  aspect-ratio: 1 / 1;

  gap: clamp(2px, 0.8vw, 5px);

  padding: clamp(3px, 0.8vw, 6px);

  overflow: hidden;

  background:
    linear-gradient(
      145deg,
      #6e482a,
      #93653b
    );

  border:
    2px solid rgba(91, 64, 45, 0.55);

  border-radius: 12px;

  box-shadow:
    inset 0 4px 10px rgba(55, 36, 22, 0.28),
    0 1px 0 rgba(255, 255, 255, 0.25);
}


/* =========================================================
   パズルピース
========================================================= */

.puzzle-tile {
  position: relative;

  width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1;

  padding: 0;

  overflow: hidden;

  background-color: var(--paper-deep);
  background-repeat: no-repeat;

  border:
    1px solid rgba(91, 64, 45, 0.44);

  border-radius:
    clamp(3px, 1vw, 7px);

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.52),
    0 2px 4px rgba(55, 36, 22, 0.26);

  cursor: pointer;

  touch-action: manipulation;

  transition:
    transform 0.1s ease,
    filter 0.1s ease,
    box-shadow 0.1s ease;
}


.puzzle-tile::after {
  content: "";

  position: absolute;
  inset: 0;

  background:
    linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.13),
      transparent 42%,
      rgba(55, 36, 22, 0.08)
    );

  pointer-events: none;
}


.puzzle-tile:active {
  transform: scale(0.96);

  filter: brightness(0.95);

  box-shadow:
    inset 0 1px 3px rgba(55, 36, 22, 0.2);
}


/* =========================================================
   空白マス
========================================================= */

.puzzle-empty {
  width: 100%;
  aspect-ratio: 1 / 1;

  background:
    radial-gradient(
      circle at center,
      rgba(255, 255, 255, 0.08),
      transparent 67%
    ),
    linear-gradient(
      145deg,
      rgba(91, 64, 45, 0.35),
      rgba(55, 36, 22, 0.47)
    );

  border:
    1px solid rgba(55, 36, 22, 0.24);

  border-radius:
    clamp(3px, 1vw, 7px);

  box-shadow:
    inset 0 3px 7px rgba(55, 36, 22, 0.32);
}


/* =========================================================
   完成時に盤面へ表示する画像
========================================================= */

.completed-board-picture {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;

  background-color: var(--paper-deep);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;

  border-radius: 7px;

  animation:
    completedPictureAppear 0.5s ease both;
}


@keyframes completedPictureAppear {
  0% {
    opacity: 0;
    transform: scale(0.94);
    filter: brightness(1.3);
  }

  60% {
    opacity: 1;
    transform: scale(1.015);
    filter: brightness(1.08);
  }

  100% {
    opacity: 1;
    transform: scale(1);
    filter: brightness(1);
  }
}


/* =========================================================
   完成見本
========================================================= */

.reference-area {
  width: min(100%, 520px);

  margin: 18px auto 0;
}


.reference-details {
  overflow: hidden;

  background:
    rgba(255, 253, 247, 0.88);

  border:
    1px solid rgba(121, 80, 45, 0.19);

  border-radius: 15px;

  box-shadow:
    0 6px 15px rgba(83, 58, 37, 0.1);
}


.reference-details summary {
  display: flex;
  align-items: center;
  justify-content: center;

  min-height: 48px;

  padding: 11px 16px;

  color: var(--brown);

  font-size: 14px;
  font-weight: 800;

  list-style: none;

  cursor: pointer;

  user-select: none;
}


.reference-details summary::-webkit-details-marker {
  display: none;
}


.reference-details summary::before {
  content: "＋";

  display: inline-grid;
  place-items: center;

  width: 22px;
  height: 22px;

  margin-right: 8px;

  color: #fff;

  font-size: 15px;
  line-height: 1;

  background: var(--pink);
  border-radius: 50%;

  transition:
    transform 0.2s ease,
    background-color 0.2s ease;
}


.reference-details[open] summary::before {
  content: "−";

  background: var(--pink-dark);

  transform: rotate(180deg);
}


.reference-details[open] summary {
  border-bottom:
    1px solid rgba(121, 80, 45, 0.14);
}


.reference-image-wrap {
  width: min(100%, 340px);

  margin: 0 auto;
  padding: 15px;
}


.reference-image {
  width: 100%;
  aspect-ratio: 1 / 1;

  object-fit: cover;

  background: var(--paper-deep);

  border:
    6px solid rgba(215, 178, 122, 0.66);

  border-radius: 12px;

  box-shadow:
    0 5px 13px rgba(83, 58, 37, 0.15);
}


/* =========================================================
   ゲーム中の操作ボタン
========================================================= */

.game-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;

  gap: 12px;

  width: min(100%, 520px);

  margin: 20px auto 0;
}


.game-controls .sub-button {
  min-width: 0;
}


.shuffle-button {
  color: var(--green-dark);

  background:
    linear-gradient(
      180deg,
      #f9fcf5,
      #e7efdf
    );

  border-color:
    rgba(83, 101, 74, 0.4);

  box-shadow:
    0 5px 0 rgba(83, 101, 74, 0.22),
    0 8px 14px rgba(83, 101, 74, 0.1);
}


.shuffle-button:active {
  box-shadow:
    0 2px 0 rgba(83, 101, 74, 0.22),
    0 4px 8px rgba(83, 101, 74, 0.08);
}


.back-button {
  color: var(--brown-soft);
}


/* =========================================================
   ゲーム中の補足文
========================================================= */

.game-hint {
  width: min(100%, 520px);

  margin: 15px auto 0;

  color: var(--brown-soft);

  font-size: 12px;
  line-height: 1.7;

  text-align: center;
}


/* ===== ここまでCSS後半① ===== */

/* =========================================================
   クリア画面
========================================================= */

.clear-screen {
  width: 100%;

  padding-top: 16px;

  animation: screenFade 0.4s ease;
}


.clear-card {
  position: relative;

  width: min(100%, 560px);

  margin: 0 auto;
  padding: 30px 24px 26px;

  text-align: center;

  background:
    linear-gradient(
      160deg,
      rgba(255, 255, 255, 0.97),
      rgba(255, 249, 236, 0.97)
    );

  border:
    1px solid rgba(121, 80, 45, 0.2);

  border-radius: var(--radius-large);

  box-shadow: var(--shadow-card);
}


.clear-card::before {
  content: "";

  position: absolute;
  inset: 9px;

  border:
    1px dashed rgba(173, 123, 69, 0.25);

  border-radius:
    calc(var(--radius-large) - 8px);

  pointer-events: none;
}


.clear-label {
  position: relative;
  z-index: 1;

  display: inline-block;

  margin: 0 0 12px;
  padding: 6px 16px;

  color: #fff;

  font-size: 13px;
  font-weight: 800;

  letter-spacing: 0.12em;

  background:
    linear-gradient(
      180deg,
      #d59ba0,
      var(--pink)
    );

  border-radius: 999px;

  box-shadow:
    0 4px 10px rgba(169, 111, 115, 0.2);
}


.clear-title {
  position: relative;
  z-index: 1;

  margin: 0;

  color: var(--brown);

  font-size: clamp(27px, 7vw, 40px);
  line-height: 1.35;
}


.clear-message {
  position: relative;
  z-index: 1;

  margin: 10px 0 22px;

  color: var(--brown-soft);

  font-size: 15px;
  line-height: 1.8;
}


/* =========================================================
   クリア画像
========================================================= */

.completed-image-wrap {
  position: relative;
  z-index: 1;

  width: min(100%, 400px);
  aspect-ratio: 1 / 1;

  margin: 0 auto;
  padding: 10px;

  background:
    linear-gradient(
      145deg,
      var(--wood-light),
      var(--wood),
      var(--wood-dark)
    );

  border-radius: 18px;

  box-shadow:
    0 10px 22px rgba(83, 58, 37, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);

  animation:
    clearImageAppear 0.6s ease both;
}


.completed-image {
  width: 100%;
  height: 100%;

  object-fit: cover;

  background: var(--paper-deep);

  border-radius: 10px;
}


@keyframes clearImageAppear {
  from {
    opacity: 0;
    transform:
      translateY(10px)
      scale(0.95);
  }

  to {
    opacity: 1;
    transform:
      translateY(0)
      scale(1);
  }
}


/* =========================================================
   今回の記録
========================================================= */

.clear-result {
  position: relative;
  z-index: 1;

  display: grid;
  grid-template-columns: 1fr 1fr;

  gap: 12px;

  width: min(100%, 400px);

  margin: 22px auto 0;
}


.clear-result-item {
  display: flex;
  flex-direction: column;
  align-items: center;

  gap: 4px;

  padding: 14px 10px;

  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.92),
      rgba(247, 240, 223, 0.92)
    );

  border:
    1px solid rgba(121, 80, 45, 0.18);

  border-radius: 14px;

  box-shadow:
    0 5px 12px rgba(83, 58, 37, 0.09);
}


.clear-result-label {
  color: var(--brown-soft);

  font-size: 12px;
  font-weight: 700;
}


.clear-result-item strong {
  color: var(--brown);

  font-size: 24px;

  font-variant-numeric: tabular-nums;
}


/* =========================================================
   新記録
========================================================= */

.new-record-message {
  position: relative;
  z-index: 1;

  margin: 16px auto 0;
  padding: 10px 15px;

  width: fit-content;
  max-width: 100%;

  color: #80551d;

  font-size: 14px;
  font-weight: 800;
  line-height: 1.6;

  background:
    linear-gradient(
      180deg,
      #fff8d8,
      #f4e5a8
    );

  border:
    1px solid rgba(185, 139, 67, 0.44);

  border-radius: 999px;

  box-shadow:
    0 5px 13px rgba(185, 139, 67, 0.16);

  animation:
    recordBounce 0.55s ease both;
}


@keyframes recordBounce {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }

  60% {
    opacity: 1;
    transform: scale(1.06);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}


/* =========================================================
   ベスト記録
========================================================= */

.best-record-area {
  position: relative;
  z-index: 1;

  width: min(100%, 400px);

  margin: 18px auto 0;
  padding: 16px;

  background:
    rgba(243, 231, 205, 0.55);

  border:
    1px solid rgba(121, 80, 45, 0.15);

  border-radius: 15px;
}


.best-record-title {
  margin: 0 0 11px;

  color: var(--brown);

  font-size: 14px;
  font-weight: 800;
}


.best-record-list {
  display: grid;
  grid-template-columns: 1fr 1fr;

  gap: 10px;

  margin: 0;
}


.best-record-item {
  margin: 0;
  padding: 10px 8px;

  background:
    rgba(255, 255, 255, 0.64);

  border-radius: 11px;
}


.best-record-item dt {
  margin: 0 0 3px;

  color: var(--brown-soft);

  font-size: 11px;
  font-weight: 700;
}


.best-record-item dd {
  margin: 0;

  color: var(--green-dark);

  font-size: 19px;
  font-weight: 800;

  font-variant-numeric: tabular-nums;
}


/* =========================================================
   クリア後のボタン
========================================================= */

.clear-controls {
  position: relative;
  z-index: 1;

  display: grid;
  grid-template-columns: 1fr 1fr;

  gap: 12px;

  width: min(100%, 400px);

  margin: 22px auto 0;
}


.clear-controls .main-button,
.clear-controls .sub-button {
  min-width: 0;
}


.clear-back-area {
  position: relative;
  z-index: 1;

  width: min(100%, 400px);

  margin: 8px auto 0;
}


/* =========================================================
   タブレット以下
========================================================= */

@media (max-width: 700px) {
  .game-container {
    padding-left:
      max(14px, env(safe-area-inset-left));

    padding-right:
      max(14px, env(safe-area-inset-right));
  }


  .game-header {
    padding-top: 58px;
  }


  .memory-card {
    padding: 21px 17px;
  }


  .puzzle-frame {
    padding: 11px;

    border-radius: 18px;
  }


  .clear-card {
    padding: 27px 17px 23px;
  }
}


/* =========================================================
   スマートフォン
========================================================= */

@media (max-width: 480px) {
  .game-container {
    padding-top:
      max(18px, env(safe-area-inset-top));

    padding-bottom:
      max(26px, env(safe-area-inset-bottom));
  }


  .sound-toggle-button {
    top:
      max(12px, env(safe-area-inset-top));

    right:
      max(12px, env(safe-area-inset-right));

    min-height: 38px;

    padding: 7px 10px;
  }


  .sound-toggle-text {
    font-size: 12px;
  }


  .game-header {
    padding:
      50px 4px 17px;
  }


  .game-description {
    font-size: 14px;
  }


  .mobile-break {
    display: initial;
  }


  .start-screen {
    gap: 17px;
  }


  .memory-card {
    padding:
      19px 13px 18px;

    border-radius: 19px;
  }


  .memory-card::before {
    inset: 6px;
  }


  .memory-card::after {
    top: 12px;

    width: 60px;
    height: 13px;
  }


  .memory-card-label {
    margin-top: 8px;
  }


  .memory-preview-wrap {
    padding: 8px;

    border-radius: 14px;
  }


  .memory-title {
    margin-top: 15px;

    font-size: 21px;
  }


  .difficulty-area {
    padding: 16px 12px;
  }


  .difficulty-buttons {
    gap: 7px;
  }


  .difficulty-option span {
    min-height: 68px;

    padding: 8px 4px;

    border-radius: 11px;
  }


  .difficulty-option strong {
    font-size: 17px;
  }


  .difficulty-option small {
    font-size: 10px;
  }


  .main-button {
    min-height: 54px;

    font-size: 16px;
  }


  .status-panel {
    margin-bottom: 13px;
    padding: 11px 12px;
  }


  .status-item strong {
    font-size: 20px;
  }


  .status-divider {
    margin: 0 12px;
  }


  .puzzle-frame {
    padding: 8px;

    border-radius: 15px;
  }


  .puzzle-board {
    gap: 2px;
    padding: 3px;

    border-radius: 9px;
  }


  .reference-area {
    margin-top: 14px;
  }


  .game-controls {
    gap: 9px;

    margin-top: 16px;
  }


  .game-controls .sub-button {
    padding:
      10px 7px;

    font-size: 13px;
  }


  .clear-card {
    padding:
      25px 13px 20px;

    border-radius: 19px;
  }


  .clear-message {
    font-size: 14px;
  }


  .completed-image-wrap {
    padding: 8px;

    border-radius: 14px;
  }


  .clear-result {
    gap: 8px;

    margin-top: 17px;
  }


  .clear-result-item {
    padding: 11px 7px;
  }


  .clear-result-item strong {
    font-size: 21px;
  }


  .best-record-area {
    padding: 13px 10px;
  }


  .clear-controls {
    gap: 9px;

    margin-top: 18px;
  }


  .clear-controls .main-button,
  .clear-controls .sub-button {
    padding:
      11px 7px;

    font-size: 13px;
  }
}


/* =========================================================
   とても小さな画面
========================================================= */

@media (max-width: 350px) {
  .sound-toggle-text {
    display: none;
  }


  .sound-toggle-button {
    width: 40px;
    height: 40px;

    padding: 0;

    border-radius: 50%;
  }


  .difficulty-buttons {
    grid-template-columns: 1fr;
  }


  .difficulty-option span {
    min-height: 54px;
  }


  .game-controls,
  .clear-controls {
    grid-template-columns: 1fr;
  }


  .clear-result,
  .best-record-list {
    grid-template-columns: 1fr;
  }
}


/* =========================================================
   横向きで高さが低い画面
========================================================= */

@media (
  orientation: landscape
) and (
  max-height: 620px
) {
  .game-container {
    width: min(100%, 940px);

    padding-top: 12px;
    padding-bottom: 18px;
  }


  .game-header {
    padding:
      38px 10px 12px;
  }


  .game-header h1 {
    font-size: 29px;
  }


  .game-description {
    margin-top: 7px;

    font-size: 13px;
  }


  .memory-preview-wrap {
    width: min(43vh, 350px);
  }


  .puzzle-frame {
    width: min(70vh, 480px);
  }


  .completed-image-wrap {
    width: min(48vh, 350px);
  }
}


/* =========================================================
   マウス操作が使える端末
========================================================= */

@media (hover: hover) {
  .sound-toggle-button:hover {
    transform: translateY(-1px);

    box-shadow:
      0 7px 17px rgba(83, 58, 37, 0.16);
  }


  .change-memory-button:hover {
    background:
      rgba(238, 244, 233, 0.94);
  }


  .difficulty-option:hover span {
    transform: translateY(-2px);

    border-color:
      rgba(114, 134, 101, 0.48);
  }


  .main-button:hover,
  .sub-button:hover {
    filter: brightness(1.04);
  }


  .text-button:hover {
    color: var(--green-dark);
  }


  .puzzle-tile:hover {
    filter: brightness(1.05);

    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.62),
      0 3px 6px rgba(55, 36, 22, 0.32);
  }


  .reference-details summary:hover {
    background:
      rgba(243, 231, 205, 0.38);
  }
}


/* =========================================================
   動きを減らす設定
========================================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;

    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;

    transition-duration: 0.01ms !important;
  }
}


/* ===== style.css 完成 ===== */