body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #f4f4f4;
}

.body-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Header */
.site-header {
    text-align: center;
    padding: 16px;
    border-bottom: 1px solid #ddd;
    background: #fff;
}

.site-header h1 {
    margin-bottom: 0;
}

.site-header h1 a {
    text-decoration: none;
    color: inherit;
}

.site-header h2 {
    margin-top: 0;
    color: #b58863;
}

h3 {
  margin-bottom: 10px;
  text-align: center;
  font-size: 20px;
}

/* Footer */
.site-footer {
    position: static;
    text-align: center;
    padding: 16px;
    border-top: 1px solid #ddd;
    background: #fff;
    font-size: 0.8rem;
}

.site-footer a {
    color: #0066cc;
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

.footer-sep {
    margin: 0 6px;
    color: #aaa;
}

.site-footer p {
  color: #555;
}

/* Main Wrapper */
.content {
  flex: 1;
  margin: 24px auto;
  padding: 0 16px;
}

.sample-wrapper {
  max-width: min(90vmin, 480px);
  margin: 0 auto 50px;
  padding: 20px 0;
  background-color: rgba(230,0,0,0.1);
  display: block;
}

.sample-wrapper p {
  text-align: center;
  margin: 5px auto;
  font-weight: bold;
  color: #8b0000;
  font-size: 1.5rem;
}

.sample-wrapper ul {
  width: 70%;
  margin: auto auto;
}


.result-wrapper {
  text-align: center;
}

.result-wrapper #result-text {
  margin-bottom: 40px;
}

/* --------------- */
/* Game Analysis   */
/* --------------- */
.game-analysis {
  padding-bottom: 20px;
  max-width: min(90vmin, 480px);
  margin: 0 auto;
}

.game-analysis p {
  text-align: center;
}

.analysis-class {
  font-weight: bold;
  padding: 10px 0;
  border-style: solid;
  border-width: 1px 0;
  margin-top: 0;
  background-color: #f0d9b5;
}

/* ===== Tabs ===== */
.tab-menu {
  display: flex;
  justify-content: center;
}

.tab-btn {
    width: 50%;
    padding: 10px 20px;
    border: none;
    background: #ddd;
    cursor: pointer;
    font-size: 16px;
}

.tab-btn.active {
  background: #333;
  color: #fff;
}

.tab-content {
  display: none;
  border-style: solid;
  border-width: 0 1px 1px 1px;
}

.tab-content.active {
  display: block;
}

.chart-wrapper {
    width: 90%;
    max-width: 800px;
    height: 300px;   /* ← ここが本体 */
    margin: 20px auto 10px;
}

.chart-explanation {
  margin: 0 auto 20px;
  width: 70%;
  font-size: 0.6rem;
  text-align: left;
}

.chart-explanation-item {
  margin-bottom: 10px;
  color: #333;
}

.chart-label {
  font-weight: bold;
}

.moves-class {
  margin-bottom: 5px;
  font-weight: bold;
}

.good-move-wrapper {
  margin-bottom: 30px;
}

.good-move {
  display: flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  margin: 0 auto;
}

.good-move .label {
  white-space: nowrap;
}

.good-move .value {
  font-weight: bold;
  padding-left: 6px;
  color: #090;
}

.good-move img {
  width: 25px;
  height: 25px;
}

.mistake-moves-wrapper {
  margin-bottom: 30px;
}

.analysis-table {
    width: 95%;
    border-collapse: collapse;
    text-align: center;
    table-layout: fixed;
    margin: 0 auto;
}

.analysis-table thead {
  background-color: #797979;
}

.analysis-table th,
.analysis-table td {
    border: 1px solid #ddd;
    padding: 8px;
}

.analysis-table th {
    color: #fff;
}

.analysis-table td {
  word-break: break-all;        /* 強制改行 */
  overflow-wrap: anywhere;
  white-space: normal;
}

.analysis-table .move-no {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
}

.analysis-table td.your-move {
    color: #c00;
}

.analysis-table td.better-move {
    color: #090;
    position: relative;
    background-color: #f9f9f9;
}

.analysis-table td.explanation {
    position: relative;
}

.move-no-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.back-button {
  width: 25px;
  height: 25px;
  padding: 6px;
  margin: 0 10px;
  
  background-color: #f4f4f4;
  border: none;
  border-radius: 6px;
  cursor: pointer;

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

  transition: background-color 0.25s ease, transform 0.1s ease;
}

.back-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.explanation {
    background: #f9f9f9;
    text-align: left;
}

.explanation-text {
    font-size: 0.9em;
    line-height: 1.6;
    word-break: break-word;
}


.advice-wrapper {
  margin-bottom: 30px;
}

.advice-title {
  display: flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  margin: 0 auto;
}

.advice-title-text {
  margin: 0;
  font-weight: bold;
}

.advice-title img {
  width: 20px;
  height: 20px;
  margin-bottom: 2px;
}

.advice {
  width: 90%;
  margin: 10px auto;
  background: #f9f9f9;
  text-align: left;
  position: relative;
}

.advice-text {
  font-size: 0.9rem;
  line-height: 1.6;
  word-break: break-word;
  padding: 5px 10px 10px;
}

.advice-ul {
  font-size: 0.9rem;
  line-height: 1.6;
  word-break: break-word;
  padding-left: 25px;
  margin: 5px auto 10px;
}

.locked {
    filter: blur(6px);
    opacity: 0.5;
    user-select: none;
    pointer-events: none;
}

.premium-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
}

.premium-overlay img {
    width: 20px;
    height: 20px;
}

.premium-contents {
  width: 90%;
  margin: 0 auto 30px;
  padding: 10px 0;
  background-color: rgba(230,195,0,0.1); /* #e6c300 */
  display: block;
}

.premium-contents-text {
  width: 90%;
  margin: 0 auto;
}

.premium-button {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin: 20px auto 10px;
}

.premium-button-text {
  font-weight: bold;
}

.premium-button button {
  width: 132px;
  height: 60px;
  padding: 10px;
  
  border: none;
  border-radius: 30px;
  cursor: pointer;
  
  font-size: 14px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  transition: background-color 0.25s ease, transform 0.1s ease;
}

.premium-button button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.premium-button button span {
  display: flex;
  align-items: center;   /* ← 高さ中央揃え */
}

#unlock-white {
  background-color: #fff;
}


#unlock-black {
  background-color: #333;
  color: #fff
}

.unlock-both {
  background-color: #e6c300;
}


.premium-button img {
    width: 17px;
    height: 17px;
}

.forvisiter-text {
  font-size: 0.8rem;
}


/* sample-page */
.sample-page {
    position: static;
    text-align: center;
    padding-top: 10px;
    font-size: 0.8rem;
}

.sample-page a {
    color: #333;
    text-decoration: none;
}

.sample-page a:hover {
    text-decoration: underline;
}


/* --------------- */
/* Note Wrapper */
/* --------------- */
.note-wrapper {
  width: 90%;
  margin: 0 auto;
}

.note-sub {
  color: #8b0000;
  margin-bottom: 0;
}

.note-wrapper ul {
  margin-top: 8px;
  margin-right: 20px;
}

.note-wrapper li {
  font-size: 0.8rem;
  margin-bottom: 5px;
  color: #333;
}

/* --------------- */
/* Replayer Wrapper */
/* --------------- */

#replay-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding-top: 20px;
}

#replay-wrapper p {
  margin: 0 auto 20px;
  font-size: 0.8rem;
  color: #333;
}

.captured-area {
  width: min(90%, 250px);
  display: flex;
  justify-content: center;
}

.captured {
  width: 100%;
  height:20px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  padding: 2px;
}

#captured-top {
  background-color: #333;  /* 白背景に白い駒が見やすい */
  transform: rotate(180deg);  /* 180度回転 */
}

#captured-bottom {
  background-color: #fff;  /* 黒に近い灰色 */
}

.captured-piece {
  width: 15px;  /* 駒のサイズ調整 */
  height: 15px;  /* 駒のサイズ調整 */
  object-fit: contain;
  display: inline-block;
}


/* --------------- */
/* Board Wrapper */
/* --------------- */
#board-wrapper {
  --board-size: min(70vmin, 480px);

  display: grid;
  grid-template-columns: auto var(--board-size) auto;
  grid-template-rows: auto var(--board-size) auto;
  gap: 4px;
  padding: 4px;
  justify-content: center;
  align-items: center;
}

#replay-wrapper.rotated #board-wrapper {
  transform: rotateZ(-180deg);
  transform-origin: center;
}

/* --------------- */
/* Board Label     */
/* --------------- */
/* Top and Bottom */
.file-labels {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  font-size: 14px;
  text-align: center;
  color: #444;
}

/* Left and Right */
.rank-labels {
  height: var(--board-size);
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  font-size: 14px;
  align-items: center;
  text-align: center;
  color: #444;
}

/* Top  */
.top-files {
  grid-column: 2;
  grid-row: 1;
  transform: rotate(180deg);
}

/* Bottom */
.bottom-files {
  grid-column: 2;
  grid-row: 3;
}

/* Left */
.left-ranks {
  grid-column: 1;
  grid-row: 2;
}

/* Right */
.right-ranks {
  grid-column: 3;
  grid-row: 2;
  transform: rotate(180deg);
}

/* --------------- */
/* Board           */
/* --------------- */
#board {
  width: var(--board-size);
  height: var(--board-size);
  display: grid;
  grid-column: 2;
  grid-row: 2;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  background-color: #ddd;
  user-select: none;
  position: relative;
  pointer-events: none;
}

.square {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s; /* 背景色変更のスムーズなアニメーション */
  cursor: default;
}

.square.light { background-color: #f0d9b5; }
.square.dark  { background-color: #b58863; }

.piece {
  width: 90%;
  height: 90%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  cursor: default;
  pointer-events: none;
}


/* --------------- */
/* Board Rotated   */
/* --------------- */
.rotated #captured-top {
  background-color: #fff;
}

.rotated #captured-bottom {
  background-color: #333;
}


/* --------------- */
/* Navigate Button */
/* --------------- */
#button-navigate {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  margin: 30px 0;
}

#button-navigate button {
  width: 42px;
  height: 42px;
  padding: 6px;
  margin: 0 10px;
  
  background-color: #797979;
  border: none;
  border-radius: 6px;
  cursor: pointer;

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

  transition: background-color 0.25s ease, transform 0.1s ease;
}


#button-navigate button img {
  width: 70%;
  height: 70%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}


/* hover */
#button-navigate button:hover {
  background-color: #4a4a4a;
  transform: scale(1.07);
}


/* --------------- */
/* Moves pane      */
/* --------------- */
#moves-pane {
  text-align: left;
  margin-bottom: 30px;
}

#pgn {
  max-height: 300px;
  overflow-y: auto;
  padding: 10px;
  margin-top: 0px;
}

#pgn-table {
  width: 150px;
  border-collapse: collapse;
  border: 1px solid #333;
  margin-left: auto;
  margin-right: auto;
}

#pgn-table th,
#pgn-table td {
  border: 1px solid #333;
  padding: 4px;
}

#pgn-table th {
  text-align: center;
}

#pgn-table td {
  text-align: left;
}

#button-pgn {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}

#moves-pane #button-pgn button {
  background-color: #2196F3;
  margin: 0 10px;
}

/* hover */
#moves-pane #button-pgn button:hover {
  background-color: #0b7dda;
  transform: scale(1.07);
}


/* --------------- */
/* Popup Overlay共通 */
/* --------------- */
#popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    display: none;
    overflow: hidden;
}

/* --------------- */
/* Bot Thinking Spinner */
/* --------------- */
.hidden {
  display: none !important; 
}

#engine-spinner {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1200;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid #ddd;
  border-top-color: #333;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.bot-thinking {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;   /* アイコンサイズ */
  height: 32px;
  transform: translate(-50%, -50%);
  pointer-events: none; /* クリック透過 */
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* --------------- */
/* Caution Popup */
/* --------------- */

#caution-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 10px;
    background: #fff;
    padding: 20px 24px;
    width: min(70vmin, 300px);
    text-align: center;
    z-index: 1100;
    display: none; /* 最初は非表示 */
}

#caution-text {
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.caution-buttons {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.btn {
    flex: 1;
    padding: 8px 0;
    border-radius: 4px;
    border: none;
    cursor: pointer;
}

.btn-primary {
    background: #d9534f;
    color: #fff;
}

.btn-secondary {
    background: #e0e0e0;
}



/* --------------- */
/* Error Popup     */
/* --------------- */
#error-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 10px;
    background: #fff;
    padding: 20px 24px;
    width: min(70vmin, 300px);
    text-align: center;
    z-index: 1101;
    display: none;
}

#error-text {
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Close Button */
#closePopupBtn {
    justify-content: center;
    align-self: center;
    text-align: center;
    margin: 0 auto;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    width: 80px;
    height: 32px;
    
    background: #e0e0e0;
}


/* --------------- */
/* Share Buttons     */
/* --------------- */
.share-buttons {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.share-btn {
  padding: 6px;
  width: 25px;
  height: 25px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.share-btn i {
  font-size: 22px;
  color: #fff;
}

.share-btn.x { background: #000; }
.share-btn.facebook { background: #1877f2; }
.share-btn.whatsapp { background: #06c755; }
.share-btn.line { background: #06c755; }

.share-text {
  font-weight: bold;
  text-align: center;
}