/* CSS Reset - 実際に使用される要素のみ */
html, body, div, span,
h2, p, a, img,
header, footer, section, main, ul, li,
input, button, select, option {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
}

/* HTML5 display-role reset */
footer, header, main, section {
	display: block;
}

body {
	line-height: 1;
}

ul {
	list-style: none;
}

/* ローカルフォントの定義（使用するフォントのみ） */
/* m-plus-1p-500 - japanese_latin */
@font-face {
  font-display: swap;
  font-family: 'M PLUS 1p';
  font-style: normal;
  font-weight: 500;
  src: url('../fonts/m-plus-1p-v31-japanese_latin-500.woff2') format('woff2');
}

/* m-plus-1p-700 - japanese_latin */
@font-face {
  font-display: swap;
  font-family: 'M PLUS 1p';
  font-style: normal;
  font-weight: 700;
  src: url('../fonts/m-plus-1p-v31-japanese_latin-700.woff2') format('woff2');
}

/* mochiy-pop-p-one-regular - japanese_latin */
@font-face {
  font-display: swap;
  font-family: 'Mochiy Pop P One';
  font-style: normal;
  font-weight: 400;
  src: url('../fonts/mochiy-pop-p-one-v11-japanese_latin-regular.woff2') format('woff2');
}

/* zen-kaku-gothic-new-500 - japanese_latin */
@font-face {
  font-display: swap;
  font-family: 'Zen Kaku Gothic New';
  font-style: normal;
  font-weight: 500;
  src: url('../fonts/zen-kaku-gothic-new-v17-japanese_latin-500.woff2') format('woff2');
}

/* Critical CSS - Above the fold styles */
html {
    box-sizing: border-box;
    font-family: 'M PLUS 1p', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0 auto;
    overflow-x: hidden;
}

body {
    background-color: #f2fff1;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== コンテンツラッパー ===== */
.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ===== ヘッダー（Critical） ===== */
header {
    text-align: center;
    padding: 30px 0;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 2px 12px 0 rgba(0,0,0,0.06);
}

.h1-image {
    width: 120px;
    height: auto;
}

/* ===== メインコンテンツ（Critical） ===== */
main {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 40px 20px;
}

.form-section {
    width: 100%;
    max-width: 800px;
    text-align: center;
}

/* ===== 見出し（Critical） ===== */
h2 {
    font-family: "Mochiy Pop P One", sans-serif;
    font-weight: 400;
    font-size: 28px;
    color: #242424;
    margin-bottom: 30px;
    line-height: 1.4;
    text-align: center;
}

/* ===== リアルタイム接続状態表示 ===== */
.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 0 auto 20px auto;
    max-width: 200px;
    font-family: "M PLUS 1p", sans-serif;
    font-size: 14px;
    transition: all 0.3s ease;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #999;
    animation: pulse 2s ease-in-out infinite;
}

.status-indicator.connecting {
    background: #ffa500;
}

.status-indicator.connected {
    background: #00E1A9;
}

.status-indicator.error {
    background: #ff6b6b;
    animation: none;
}

.status-text {
    font-weight: 500;
    color: #666;
}

.connection-status.connected .status-text {
    color: #00E1A9;
}

.connection-status.error .status-text {
    color: #ff6b6b;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.8);
    }
}

/* ===== 入力セクション（Critical） ===== */
.input-section {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 40px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

#itemInput {
    flex: 1;
    height: 54px;
    padding: 0 20px;
    border: 2px solid #C6EBE2;
    border-radius: 8px;
    font-family: "M PLUS 1p", sans-serif;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    min-width: 0;
    background-color: #fff;
}

#itemInput:focus {
    border-color: #00E1A9;
}

#addButton {
    width: 80px;
    height: 54px;
    padding: 0;
    background-color: #00E1A9;
    border: none;
    border-radius: 8px;
    color: white;
    font-family: "M PLUS 1p", sans-serif;
    font-weight: 700;
    font-size: 18px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: nowrap;
    box-sizing: border-box;
    flex-shrink: 0;
}

#addButton:hover {
    background-color: #00c995;
}

/* Items List */
.items-list {
    margin-bottom: 40px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* Column Headers（最適化） */
.column-headers {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    padding: 12px 16px 10px 16px;
    border-bottom: 1px solid #C6EBE2;
}

.column-headers-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1.5fr 1.5fr 1.5fr;
    gap: 12px;
    align-items: center;
    min-width: 0;
    justify-items: center;
}

.column-header {
    font-family: "M PLUS 1p", sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: #404040;
    text-align: center;
    padding: 0;
}

.header-spacer {
    width: 32px;
    flex-shrink: 0;
}

/* Item Row（最適化） */
.item-row {
    background: rgba(232, 248, 245, 0.8);
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 8px;
    border-left: 4px solid #00E1A9;
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    will-change: transform, opacity;
}

/* Item Content */
.item-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1.5fr 1.5fr 1.5fr;
    gap: 12px;
    align-items: center;
    min-width: 0;
    justify-items: center;
}

.item-name {
    font-size: 16px;
    font-family: "M PLUS 1p", sans-serif;
    font-weight: 700;
    color: #333;
    text-align: center;
    padding: 0 12px;
    background: white;
    border-radius: 6px;
    border: 2px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    box-sizing: border-box;
    word-break: break-all;
    overflow-wrap: break-word;
    line-height: 1.2;
    width: 100%;
    min-width: 100px;
}

.item-select {
    padding: 0 8px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: white;
    font-size: 16px;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s ease;
    min-width: 0;
    height: 44px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    width: 100%;
    text-align: center;
	text-align-last: center;
    min-width: 80px;
    font-family: "M PLUS 1p", sans-serif;
}

/* 初期状態（選択してください）の色をグレーに */
.item-select[data-type="assignee"]:has(option[value=""]:checked) {
    color: #999;  /* placeholderと同じグレー */
}

/* 何か選択されたら通常の色に戻す */
.item-select[data-type="assignee"]:not(:has(option[value=""]:checked)) {
    color: #333;
}

.item-select:focus {
    outline: none;
    border-color: #00E1A9;
}

.item-select option[value="全員"] {
    font-weight: bold;
    color: #00E1A9;
}

/* Quantity Input Field */
.quantity-input {
    font-family: "M PLUS 1p", sans-serif;
}

/* Quantity Error State */
.quantity-error {
    border-color: #ff6b6b !important;
    color: #ff6b6b;
}

.quantity-error::placeholder {
    color: #ff6b6b;
    opacity: 1;
}

/* No Items Message */
.no-items-message {
    font-family: "M PLUS 1p", sans-serif;
    text-align: center;
    color: #666;
    padding: 50px 30px;
    background: rgba(232, 248, 245, 0.5);
    border-radius: 8px;
    border: 2px dashed #c0c0c0;
    display: none;
    margin: 0 auto;
    max-width: 600px;
}

.no-items-message p {
    margin: 10px 0;
    font-size: 16px;
    line-height: 1.6;
}

.no-items-message p:first-child {
    font-weight: 700;
    color: #242424;
    font-size: 18px;
}

/* Delete Button（最適化） */
.delete-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background-color: #00E1A9;
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
    position: relative;
    aspect-ratio: 1/1;
    min-width: 32px;
    max-width: 32px;
    padding: 0;
    box-sizing: border-box;
    will-change: transform, background-color;
}

.delete-btn:hover {
    background-color: #00c995;
    transform: scale(1.05);
}

.delete-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Button Container */
.button-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 30px;
    flex-wrap: wrap;
}

/* Edit Button Wrapper - 横長ボタン型 */
.edit-button-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 24px;
    background: #00E1A9;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 54px;
    min-width: 200px;
    box-sizing: border-box;
}

.edit-button-wrapper:hover {
    background: #00c995;
}

/* Edit Button - アイコン部分 */
.edit-btn {
    width: auto;
    height: auto;
    background: transparent;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    pointer-events: none;
}

.edit-btn .icon {
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Edit Label - テキスト部分 */
.edit-label {
    font-size: 16px;
    font-family: "M PLUS 1p", sans-serif;
    color: white;
    font-weight: 700;
    text-align: center;
    line-height: 1;
    pointer-events: none;
    white-space: nowrap;
}

/* ===== コピー成功メッセージ ===== */
.copy-success-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translate(-50%, -20px);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1000;
    font-family: "M PLUS 1p", sans-serif;
}

.copy-success-message.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

/* ===== リアルタイム通知 ===== */
.realtime-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    background: rgba(0, 225, 169, 0.95);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    font-family: "M PLUS 1p", sans-serif;
    box-shadow: 0 4px 12px rgba(0, 225, 169, 0.3);
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1000;
    max-width: 300px;
    word-wrap: break-word;
}

.realtime-notification.show {
    opacity: 1;
    transform: translateX(0);
}

/* ===== 編集中のインジケーター（オプション：将来的に追加可能） ===== */
.item-row.editing {
    background: rgba(255, 235, 59, 0.2);
    border-left-color: #ffc107;
}

.item-row.remote-update {
    animation: highlightUpdate 0.6s ease-out;
}

@keyframes highlightUpdate {
    0% {
        background: rgba(0, 225, 169, 0.3);
    }
    100% {
        background: rgba(232, 248, 245, 0.8);
    }
}

/* ===== フッター（非Critical - 遅延読み込み可能） ===== */
footer {
    background-color: #404040;
    color: #fff;
    padding: 50px 40px 25px 40px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 80px;
}

footer hr {
    border: none;
    border-top: 1px solid #888;
    margin: 18px 0 10px 0;
    width: 100%;
    max-width: 600px;
    opacity: 0.4;
}

footer p {
    font-family: "Zen Kaku Gothic New", sans-serif;
    font-weight: 500;
    font-size: 12px;
    margin: 0;
    text-align: left;
    width: 100%;
    max-width: 600px;
}

.footer-lists {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    max-width: 600px;
    margin-bottom: 12px;
    gap: 16px;
}

.footer-lists ul {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
}

.footer-lists li {
    font-family: "Zen Kaku Gothic New", sans-serif;
    font-weight: 500;
    font-size: 15px;
    margin-bottom: 35px;
    opacity: 0.95;
    list-style-type: none;
}

.footer-lists a {
    color: #fff;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-lists a:hover {
    color: #00E1A9;
}

/* Animation（GPU最適化） */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

.item-row {
    animation: fadeIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* ===== タブレット対応（768px以下） ===== */
@media (max-width: 768px) {
    header {
        padding: 25px 0;
    }
    
    .h1-image {
        width: 100px;
    }
    
    main {
        padding: 30px 15px;
    }
    
    .form-section {
        max-width: 100%;
    }
    
    h2 {
        font-size: 24px;
        margin-bottom: 25px;
    }
    
    .connection-status {
        font-size: 13px;
        padding: 6px 12px;
        margin-bottom: 15px;
    }
    
    .status-indicator {
        width: 8px;
        height: 8px;
    }
    
    .input-section {
        gap: 10px;
        margin-bottom: 30px;
        max-width: 100%;
    }
    
    #itemInput {
        height: 50px;
        padding: 0 18px;
        font-size: 16px;
    }
    
    #addButton {
        width: 75px;
        height: 50px;
        font-size: 18px;
    }
    
    .item-row {
        padding: 10px 12px;
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .column-headers {
        padding: 10px 12px 8px 12px;
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .column-headers-content {
        gap: 8px;
    }
    
    .column-header {
        font-size: 13px;
    }
    
    .header-spacer {
        width: 28px;
    }
    
    .item-content {
        gap: 8px;
    }
    
    .item-name {
        height: 40px;
        font-size: 16px;
        padding: 0 8px;
        min-width: 80px;
    }
    
    .item-select {
        height: 40px;
        font-size: 16px;
        padding: 0 6px;
        min-width: 70px;
		text-align-last: center;
    }
    
    .delete-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
        min-width: 28px;
        max-width: 28px;
    }
    
    .no-items-message {
        padding: 40px 20px;
    }
    
    .no-items-message p {
        font-size: 15px;
    }
    
    .no-items-message p:first-child {
        font-size: 16px;
    }
    
    .button-container {
        gap: 12px;
        margin-top: 25px;
    }
    
    .edit-button-wrapper {
        gap: 8px;
        padding: 0 20px;
        height: 50px;
        min-width: 180px;
    }
    
    .edit-btn .icon {
        font-size: 16px;
    }
    
    .edit-label {
        font-size: 15px;
    }
    
    .realtime-notification {
        top: 70px;
        right: 15px;
        font-size: 13px;
        padding: 10px 16px;
        max-width: 250px;
    }
    
    footer {
        padding: 36px 24px 18px 24px;
        margin-top: 50px;
    }
    
    .footer-lists li {
        font-size: 14px;
        margin-bottom: 30px;
    }
}

/* ===== スマートフォン対応（480px以下） ===== */
@media (max-width: 480px) {
    header {
        padding: 20px 0;
    }
    
    main {
        padding: 20px 10px;
    }
    
    .form-section {
        padding: 0 10px;
    }
    
    h2 {
        font-size: 20px;
        margin-bottom: 20px;
    }
    
    .connection-status {
        font-size: 12px;
        padding: 5px 10px;
        margin-bottom: 12px;
    }
    
    .input-section {
        gap: 8px;
        margin-bottom: 25px;
    }
    
    #itemInput {
        height: 46px;
        padding: 0 15px;
        font-size: 16px;
    }
    
    #addButton {
        width: 70px;
        height: 46px;
        font-size: 16px;
    }
    
    .item-row {
        padding: 8px 10px;
        gap: 6px;
        margin-bottom: 10px;
    }
    
    .column-headers {
        padding: 8px 10px 6px 10px;
        gap: 6px;
        margin-bottom: 10px;
    }
    
    .column-headers-content {
        gap: 6px;
    }
    
    .column-header {
        font-size: 12px;
    }
    
    .header-spacer {
        width: 24px;
    }
    
    .item-content {
        gap: 6px;
    }
    
    .item-name {
        height: 36px;
        font-size: 16px;
        padding: 0 6px;
        min-width: 70px;
    }
    
    .item-select {
        height: 36px;
        font-size: 16px;
        padding: 0 4px;
        min-width: 60px;
		text-align-last: center;
    }
    
    .delete-btn {
        width: 24px;
        height: 24px;
        font-size: 12px;
        min-width: 24px;
        max-width: 24px;
    }
    
    .no-items-message {
        padding: 30px 15px;
    }
    
    .no-items-message p {
        font-size: 13px;
    }
    
    .no-items-message p:first-child {
        font-size: 14px;
    }
    
    .button-container {
        gap: 10px;
        margin-top: 20px;
    }
    
    .edit-button-wrapper {
        gap: 6px;
        padding: 0 16px;
        height: 46px;
        min-width: 150px;
    }
    
    .edit-btn .icon {
        font-size: 14px;
    }
    
    .edit-label {
        font-size: 14px;
    }
    
    .copy-success-message {
        top: 15px;
        font-size: 13px;
        padding: 10px 20px;
    }
    
    .realtime-notification {
        top: 60px;
        right: 10px;
        left: 10px;
        font-size: 12px;
        padding: 8px 12px;
        max-width: none;
    }
    
    footer {
        padding: 36px 24px 18px 24px;
    }
    
    footer p {
        font-size: 11px;
    }
    
    .footer-lists {
        gap: 12px;
        margin-bottom: 12px;
    }
    
    .footer-lists li {
        font-size: 14px;
        margin-bottom: 30px;
    }
}

/* Preload hint for critical resources */
.h1-image {
    content-visibility: auto;
}

/* Performance optimizations */
* {
    -webkit-tap-highlight-color: transparent;
}

input, select, button {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Reduce layout shifts */
.item-row,
.column-headers {
    contain: layout style paint;
}
