/* 全体デザイン設定（元デザインを100%維持） */
body {
  margin: 0;
  padding: 0;
  background: #e6ccb2 url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8zbAAAAAAXNSR0IArs4c6QAAABxpRE9UAAAAAgAAAAAAAAADAAAAKAAAAAMAAAACAAAAbAnJXDIAAAAeSURBVBjTY/jPwPD/ggFIMkAWBI6CFAE/A/D/AAAAAAAAFSAdUk/3L/AAAAAElFTkSuQmCC") repeat;
  font-family: "Hiragino Sans", "Meiryo", sans-serif;
  color: #333;
}
h1 {
  text-align: center;
  margin: 20px 0;
  font-size: 1.5rem;
  color: #4c3310;
  text-shadow: 1px 1px 0 #fefefe;
}
#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 40px;
}

/* トップナビゲーション（戻るリンク） */
.top-nav {
  margin: 12px 0 0 12px;
}
.top-nav a {
  display: inline-block;
  padding: 6px 12px;
  font-size: 14px;
  text-decoration: none;
  background-color: #f8f0e0;
  border: 2px solid #bca167;
  color: #4c3310;
  border-radius: 4px;
  box-shadow: 1px 1px 0 #bca167;
  font-weight: bold;
}
.top-nav a:hover {
  background-color: #ffe680;
}

/* 通信・ルーム制御パネル（元デザイン維持） */
#network-panel {
  background: #f2e2c4;
  border: 2px solid #bca167;
  border-radius: 6px;
  padding: 10px 15px;
  margin-bottom: 12px;
  width: 90%;
  max-width: 480px;
  box-shadow: 2px 2px 0 #bca167;
  font-size: 14px;
}
.net-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 6px;
}
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  color: #fff;
  font-size: 12px;
}
.status-offline { background: #888; }
.status-waiting { background: #d97706; }
.status-connected { background: #16a34a; }

.role-badge {
  font-size: 0.9rem;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid #bca167;
}

/* ターン表示（元デザイン維持） */
#turn-indicator {
  margin-bottom: 20px;
  font-weight: bold;
  font-size: 1.2rem;
  color: #4c3310;
  background: #f2e2c4;
  border: 2px solid #bca167;
  border-radius: 4px;
  padding: 5px 10px;
  box-shadow: 2px 2px 0 #bca167;
  text-align: center;
}

/* 持ち駒エリア（元デザイン維持） */
.row {
  display: flex;
  flex-direction: row;
  margin: 10px 0;
  justify-content: center;
  align-items: center;
}
.hand-label {
  margin-right: 10px;
  font-weight: bold;
  color: #4c3310;
}
.hand-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border: 2px solid #bca167;
  background: #f2e2c4;
  padding: 8px;
  min-height: 50px;
  width: 260px;
  border-radius: 4px;
  box-shadow: 2px 2px 0 #bca167;
  align-items: center;
}
.hand-piece {
  border: 1px solid #888;
  border-radius: 4px;
  padding: 4px 6px;
  cursor: pointer;
  font-size: 16px;
  user-select: none;
  text-align: center;
  margin: 2px;
  background-color: #ffffff;
  box-shadow: 1px 1px 0 #bbb;
}
.hand-piece:hover {
  background-color: #ffe680;
}

/* 盤（元デザイン維持 50px × 50px） */
.board {
  border-collapse: collapse;
}
.board td {
  width: 50px;
  height: 50px;
  border: 1px solid #bfa074;
  background: #fcebcf;
  text-align: center;
  vertical-align: middle;
  font-size: 20px;
  cursor: pointer;
  user-select: none;
  position: relative;
  box-shadow: inset 1px 1px 0 #bfa074;
}

/* 先手・後手の駒の色や装飾 */
.S {
  color: #d12b2b;
  font-weight: bold;
  text-shadow: 1px 1px 0 #fff;
}
.G {
  color: #004c99;
  font-weight: bold;
  text-shadow: 1px 1px 0 #fff;
}
.board td.G {
  transform: rotate(180deg);
}

/* 選択セルや可能マスのハイライト */
.selected {
  background-color: #ffccb5 !important;
}
.highlight {
  background-color: #c5f7be !important;
}

/* ボタン（元デザイン維持） */
.control-buttons {
  margin-top: 15px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.control-buttons button, .net-btn, .custom-btn {
  margin: 0 4px;
  padding: 8px 12px;
  font-size: 16px;
  background-color: #f8f0e0;
  border: 2px solid #bca167;
  color: #4c3310;
  border-radius: 4px;
  box-shadow: 1px 1px 0 #bca167;
  cursor: pointer;
  font-family: "Hiragino Sans", "Meiryo", sans-serif;
}
.control-buttons button:hover, .net-btn:hover, .custom-btn:hover {
  background-color: #ffe680;
}

/* 勝敗メッセージ表示用 */
#message-overlay, .modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.message-box {
  background: #fff;
  border: 2px solid #bca167;
  border-radius: 8px;
  padding: 20px 30px;
  text-align: center;
  box-shadow: 3px 3px 0 #bca167;
}
.message-box h2 {
  font-size: 1.4rem;
  margin-bottom: 20px;
  color: #4c3310;
}
.close-btn {
  font-size: 16px;
  padding: 6px 12px;
  background-color: #f8f0e0;
  border: 2px solid #bca167;
  color: #4c3310;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 1px 1px 0 #bca167;
  font-family: inherit;
}
.close-btn:hover {
  background-color: #ffe680;
}

/* ポータル（トップページ）スタイル */
.portal-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 20px;
}
.portal-card {
  background: #f2e2c4;
  border: 3px solid #bca167;
  border-radius: 8px;
  padding: 30px 25px;
  width: 90%;
  max-width: 440px;
  box-shadow: 3px 3px 0 #bca167;
  text-align: center;
}
.portal-subtitle {
  font-size: 1rem;
  color: #4c3310;
  margin-bottom: 25px;
  font-weight: bold;
}
.portal-menu {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.portal-btn {
  display: block;
  text-decoration: none;
  padding: 14px 20px;
  font-size: 18px;
  font-weight: bold;
  background-color: #f8f0e0;
  border: 2px solid #bca167;
  color: #4c3310;
  border-radius: 6px;
  box-shadow: 2px 2px 0 #bca167;
  cursor: pointer;
  transition: background-color 0.2s;
  text-align: center;
}
.portal-btn:hover {
  background-color: #ffe680;
}
.portal-btn small {
  display: block;
  font-size: 12px;
  font-weight: normal;
  color: #666;
  margin-top: 4px;
}

/* エクスプローラー風モーダルウィンドウ */
.explorer-window {
  background: #fbf8f2;
  border: 3px solid #bca167;
  border-radius: 8px;
  width: 95%;
  max-width: 780px;
  height: 85vh;
  max-height: 640px;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 4px 0 #bca167;
  font-size: 14px;
}
.explorer-header {
  background: #f2e2c4;
  border-bottom: 2px solid #bca167;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.explorer-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: #4c3310;
}
.explorer-toolbar {
  background: #f5ecd8;
  border-bottom: 1px solid #bca167;
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.explorer-toolbar label {
  font-weight: bold;
  color: #4c3310;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.explorer-toolbar select, .explorer-toolbar button {
  padding: 5px 8px;
  font-size: 13px;
  background-color: #f8f0e0;
  border: 1px solid #bca167;
  color: #4c3310;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}
.explorer-toolbar button:hover {
  background-color: #ffe680;
}
.explorer-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: #fff;
}
.explorer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.explorer-table th {
  background: #f2e2c4;
  border: 1px solid #bca167;
  padding: 8px 6px;
  color: #4c3310;
  text-align: left;
  user-select: none;
}
.explorer-table td {
  border: 1px solid #e0cdb0;
  padding: 8px 6px;
  vertical-align: middle;
}
.explorer-table tr:hover {
  background-color: #fff8e1;
}
.explorer-table tr.selected {
  background-color: #ffe0b2 !important;
}
.group-header {
  background: #f2e2c4;
  border: 1px solid #bca167;
  padding: 8px 12px;
  font-weight: bold;
  color: #4c3310;
  margin-top: 10px;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 4px;
}
.group-header button {
  padding: 2px 8px;
  font-size: 12px;
  background: #f8f0e0;
  border: 1px solid #bca167;
  color: #4c3310;
  border-radius: 3px;
  cursor: pointer;
}
.group-header button:hover {
  background: #ffe680;
}
.tag-mode {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: bold;
  color: #fff;
}
.tag-online { background-color: #004c99; }
.tag-offline { background-color: #2e7d32; }

/* QRコードポップアップ用 */
.qr-box {
  background: #fff;
  border: 2px solid #bca167;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  box-shadow: 3px 3px 0 #bca167;
  max-width: 320px;
  width: 90%;
}
.qr-box h3 {
  margin: 0 0 10px 0;
  color: #4c3310;
}
#qr-canvas {
  margin: 10px auto;
  display: block;
  border: 1px solid #bca167;
  background: #fff;
}

/* 参加用ポップアップ専用スタイル */
.join-box {
  background: #f2e2c4;
  border: 3px solid #bca167;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  box-shadow: 3px 3px 0 #bca167;
  max-width: 380px;
  width: 90%;
  font-size: 14px;
  color: #4c3310;
}
.join-box h3 {
  margin: 0 0 12px 0;
  font-size: 1.2rem;
  color: #4c3310;
}
.join-section {
  text-align: left;
  background: #fbf8f2;
  border: 1px solid #bca167;
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 8px;
}
.join-section h4 {
  margin: 0 0 6px 0;
  font-size: 13px;
  color: #4c3310;
}
.join-text-input {
  flex: 1;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid #bca167;
  border-radius: 4px;
  background: #fff;
  color: #333;
  outline: none;
  font-family: inherit;
}
.join-text-input:focus {
  border-color: #d12b2b;
  background: #fffdf5;
}
#qr-video {
  display: none;
  width: 100%;
  max-width: 280px;
  border-radius: 6px;
  border: 2px solid #bca167;
  margin: 10px auto 0 auto;
  background: #000;
}